Php 加载声明必须与…FixtureInterface::Load()兼容
我正在创建一个需要加载函数的条令数据装置。我从FixtureInterface.php中复制了这个方法,但我的fixture的load()却有所不同Php 加载声明必须与…FixtureInterface::Load()兼容,php,symfony,doctrine-orm,Php,Symfony,Doctrine Orm,我正在创建一个需要加载函数的条令数据装置。我从FixtureInterface.php中复制了这个方法,但我的fixture的load()却有所不同 PHP Fatal error: Declaration of PastonVerBundle\DataFixtures\ORM\LoadTimeZoneData::load() must be compatible with that of Doctrine\Common\DataFixtures\FixtureInterface::load(
PHP Fatal error: Declaration of PastonVerBundle\DataFixtures\ORM\LoadTimeZoneData::load() must be compatible with that of Doctrine\Common\DataFixtures\FixtureInterface::load() in /var/www/symfony/src/Paston/VerBundle/DataFixtures/ORM/LoadTimeZoneData.php on line 9
我的负载:
<?php
namespace PastonVerBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Paston\VerBundle\Entity\TimeZone;
class LoadTimeZoneData
implements FixtureInterface {
function load(ObjectManager $manager) {
$z = new \TimeZone();
$z->setName('Timezone');
$manager->persist($z);
$manager->flush();
}
}
?>
从FixtureInterface.php加载
namespace Doctrine\Common\DataFixtures;
use Doctrine\Common\Persistence\ObjectManager;
/**
* Interface contract for fixture classes to implement.
*
* @author Jonathan H. Wage <jonwage@gmail.com>
*/
interface FixtureInterface
{
/**
* Load data fixtures with the passed EntityManager
*
* @param Doctrine\Common\Persistence\ObjectManager $manager
*/
function load(ObjectManager $manager);
}
名称空间原则\Common\DataFixtures;
使用条令\Common\Persistence\ObjectManager;
/**
*要实现的fixture类的接口契约。
*
*@作者乔纳森·H·贝格
*/
接口固定器接口
{
/**
*使用传递的EntityManager加载数据装置
*
*@param-doctor\Common\Persistence\ObjectManager$manager
*/
函数加载(ObjectManager$manager);
}
您缺少使用条令\Common\Persistence\ObjectManager代码>:
namespace PastonVerBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Paston\VerBundle\Entity\TimeZone;
use Doctrine\Common\Persistence\ObjectManager;
class LoadTimeZoneData
implements FixtureInterface {
function load(ObjectManager $manager) {
$z = new \TimeZone();
$z->setName('Timezone');
$manager->persist($z);
$manager->flush();
}
}
您缺少使用条令\Common\Persistence\ObjectManager代码>:
namespace PastonVerBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Paston\VerBundle\Entity\TimeZone;
use Doctrine\Common\Persistence\ObjectManager;
class LoadTimeZoneData
implements FixtureInterface {
function load(ObjectManager $manager) {
$z = new \TimeZone();
$z->setName('Timezone');
$manager->persist($z);
$manager->flush();
}
}
我有相同的错误消息,但带有OrderedFixture接口
不适用于FixtureInterface本身
在我的例子中,它实际上与load()方法无关。
实际上,我忽略了添加方法getOrder(),它是
界面中的必填项
因此,这个错误消息导致我得到了错误的提示。所以有时候要小心:)我收到了相同的错误消息,但带有OrderedFixture接口
不适用于FixtureInterface本身
在我的例子中,它实际上与load()方法无关。
实际上,我忽略了添加方法getOrder(),它是
界面中的必填项
因此,这个错误消息导致我得到了错误的提示。所以有时候要小心:)