本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::factory方法的具体用法?PHP ObjectManager::factory怎么用?PHP ObjectManager::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::factory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load(ObjectManager $manager)
{
$data = array('user' => 1, 'ws' => 2, 'parentrn' => 14, 'title' => 'ExoFIX Title 1');
$user = $manager->getRepository('ClarolineCoreBundle:User')->findOneById($data['user']);
$resourceType = $manager->getRepository('ClarolineCoreBundle:Resource\\ResourceType')->findOneByName('ujm_exercise');
$ws = $manager->getRepository('ClarolineCoreBundle:Workspace\\Workspace')->findOneById($data['ws']);
$icon = $manager->getRepository('ClarolineCoreBundle:Resource\\ResourceIcon')->findOneByMimeType('custom/ujm_exercise');
$parent = $manager->getRepository('ClarolineCoreBundle:Resource\\ResourceNode')->findOneById($data['parentrn']);
//$guid = $this->container->get('claroline.utilities.misc')->generateGuid();
$node = $manager->factory('Claroline\\CoreBundle\\Entity\\Resource\\ResourceNode');
// $node = new ResourceNode();
$node->setResourceType($resourceType);
$node->setCreator($user);
$node->setCreationDate(new \Datetime());
$node->setName($data['title']);
$node->setWorkspace($ws);
$node->setMimeType('custom/ujm_exercise');
$node->setPublished(true);
$node->setActive(true);
$node->setClass('UJM\\ExoBundle\\Entity\\Exercise');
$node->setIcon($icon);
/*
$parentPath = '';
if ($parent) {
$parentPath .= $parent->getPathForDisplay() . ' / ';
}
$node->setPathForCreationLog($parentPath . 'ExoFIX Title 1');
*/
$node->setGuid('abcd');
/*
$rn->setParent();
*/
$manager->persist($node);
$manager->flush();
// $this->addReference('rn1', $node);
}