0

我在Symfony 1.4中创建了一个模块。它按预期工作。然而,当我处于dev.php模式时,我得到一个语法错误

让我们来看看:

http://honeylumpi.mobi/dev.php/panelparameter  
NOTE: panelparameter is the admin-module that I created.

我得到:

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

现在,在我得到的 第66行:actions.class.php

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

在第22PanelParameter.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;
} 

我添加了来回声,实际上是null。但我不知道为什么。我相信该代码是由Symfony自动生成的。我不知道如何解决这个问题。同样,该模块工作正常,但在dev.php中给了我这个错误。我清除了缓存等。

编辑:这是所有代码/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

}
}
4

1 回答 1

0

我不知道 sitebuilder 来制作 symfony 网站,我不知道这个工具会生成什么。

但是你有没有尝试重建你的模型?./symfony propel:build --all-classes

它是从 sitebuilder/propel 生成的类还是来自 sf1.0 导入?

于 2012-04-10T15:11:23.017 回答