I created a module in Symfony 1.4. It works as expected. Nevertheless, when I'm in the dev.php mode, I get a syntax error.
Let's see:
http://honeylumpi.mobi/dev.php/panelparameter
NOTE: panelparameter is the admin-module that I created.
I get:
Parse error: syntax error, unexpected T_STRING in /home/lola/hl/honey-lumpi/cache/cms/dev/modules/autoPanelparameter/actions/actions.class.php on line 66
Now, at line 66 of the actions.class.php
I get:
Warning: stream_get_contents() expects parameter 1 to be resource, null given in /home/lola/hl/honey-lumpi/lib/model/sitebuilder/PanelParameter.php on line 22
And in line 22 of PanelParameter.php
:
/**
* Returns the serialized value.
*
* @return string
*/
public function getSerializedValue ()
{
$res = parent::getValue();
$retval = stream_get_contents($res); <-- This is line 22!
rewind($res);
return $retval;
}
I added come echoes, and, in fact, is null. But I don't know why. I believe that that code is auto-generated by Symfony. I don't know how to solve that problem. Again, the module works fine, but in dev.php gives me that error. I cleared cache, etc.
EDIT:
This is all the code of the /home/lola/hl/honey-lumpi/lib/model/sitebuilder/PanelParameter.php
:
<?php
/**
* Subclass for representing a row from the 'PanelParameter' table.
*
*
*
* @package lib.model
*/
class PanelParameter extends BasePanelParameter
{
private $condition;
/**
* Returns the serialized value.
*
* @return string
*/
public function getSerializedValue ()
{
$res = parent::getValue();
$retval = stream_get_contents($res);
rewind($res);
return $retval;
}
/**
* Sets the value already serialized.
*
* @param string $v
*/
public function setSerializedValue ($v)
{
parent::setValue($v);
}
/**
* Returns the value of the parameter.
*
* @return mixed
*/
public function getValue ()
{
// get serialized value
$v = $this->getSerializedValue();
// unserialize
$value = @unserialize($v);
// check for error
if (false === $value)
{
if ('b:0;' != $v)
{
if (PHP_VERSION_ID < 50300)
{
gxLog::a(__CLASS__, "cannot unserialize parameter #{$this->id} {$this->name} value:{$v}");
$value = null;
}
else
{
// try to fix array indexes
$cb = create_function('$m', 'return "s:".strlen($m[1]).":\"$m[1]\"";');
$v = preg_replace_callback('/i:([0-9]{12,})/', $cb, $v);
$value = @unserialize($v);
if (false === $value)
{
gxLog::a(__CLASS__, "cannot unserialize parameter #{$this->id} {$this->name} value:{$v}");
$value = null;
}
}
}
}
// return unserialized value
return $value;
}
/**
* Sets the value for the parameter.
*
* @param mixed $v
*/
public function setValue ($v)
{
$value = @serialize($v);
parent::setValue($value);
}
/**
* Returns the name of the parameter.
*
* @return string
*/
public function __toString ()
{
return $this->getName();
}
/**
* Returns the condition object.
*
* @return gxSiteCondition
*/
public function getCondition ()
{
if (!isset($this->condition))
{
// no condition is true always
$condition = new gxSiteCondition;
$cond = parent::getCond();
if (!is_null($cond))
{
// unserialize
$condition = gxSiteCondition::createFromJson($cond);
}
// store
$this->condition = $condition;
}
return $this->condition;
}
/**
* Sets the condition.
*
* @param gxSiteCondition $c
*/
public function setCondition ($c)
{
if (!($c instanceof gxSiteCondition)) throw new Exception ('parameter is not gxSiteCondition');
// serialize
$cond = $c->toJson();
// store
$this->condition = $c;
// store condition
parent::setCond($cond);
}
/**
* Checks the condition in the provided context.
*
* @param sfContext $context
*/
public function checkCondition (sfContext $context)
{
// get condition
$condition = $this->getCondition();
// evaluate condition
return $condition ? $condition->evaluate($context) : true;
}
/**
* Returns true if the provided condition is contained
* in this object's condition.
*
* @param gxBasicCondition $c
* @return boolean
*/
public function containsCondition (gxSiteCondition $c)
{
// get condition
$condition = $this->getCondition();
// check if contained condition
return $condition ? $condition->contains($c) : true;
}
/**
* Set default value for condition if new and not set.
*
* @param PropelPDO $con
* @return int
*/
public function save (PropelPDO $con = null)
{
if ($this->isNew() && !$this->isColumnModified(PanelParameterPeer::COND))
{
$this->setCondition(new gxSiteCondition);
}
return parent::save($con);
}
/**
* Sets contents of passed object to values from current object.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param object $copyObj An object of PanelParameter (or compatible) type.
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @throws PropelException
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setName($this->name);
$copyObj->setSerializedValue($this->getSerializedValue());
$copyObj->setCond($this->cond);
$copyObj->setPanelId($this->panel_id);
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a pkey column, so set to default value
}
}
sitebuilder
? I see your model files are insidesitebuilder
folder instead ofdoctrine
(or in the model folder for propel). – j0k