本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager::find方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::find方法的具体用法?PHP ObjectManager::find怎么用?PHP ObjectManager::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Load data fixtures with the passed EntityManager
*
* @param ObjectManager|DocumentManager $manager
*/
public function load(ObjectManager $manager)
{
$contentParent = $manager->find(null, '/cms/content');
$routeParent = $manager->find(null, '/cms/routes/en/services');
$menuBase = $manager->find(null, '/cms/menu/footer');
$content = new DemoSeoContent();
$content->setParentDocument($contentParent);
$content->setName('seo-service');
$content->setTitle('SEO Service');
$content->setBody('A page about SEO service');
$metaData = new SeoMetadata();
$metaData->setMetaDescription('Description in Metadata');
$content->setSeoMetadata($metaData);
$manager->persist($content);
$manager->bindTranslation($content, 'en');
$contentRoute = new Route();
$contentRoute->setParentDocument($routeParent);
$contentRoute->setName('seo-service');
$contentRoute->setContent($content);
$manager->persist($contentRoute);
$menuNode = new MenuNode();
$menuNode->setParentDocument($menuBase);
$menuNode->setName('seo-service');
$menuNode->setLabel('SEO Services');
$menuNode->setContent($content);
$manager->persist($menuNode);
$manager->flush();
}
示例2: load
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
$session = $manager->getPhpcrSession();
$basepath = $this->container->getParameter('cmf_routing.dynamic.persistence.phpcr.route_basepath');
NodeHelper::createPath($session, $basepath);
$routeRoot = $manager->find(null, $basepath);
$basepath = $this->container->getParameter('cmf_content.persistence.phpcr.content_basepath');
NodeHelper::createPath($session, $basepath);
$parent = $manager->find(null, $basepath);
$repository = $this->container->get('sylius.repository.static_content');
$routeRepository = $this->container->get('sylius.repository.route');
// Terms of service.
$route = $routeRepository->createNew();
$route->setPosition($routeRoot, 'terms-of-service');
$manager->persist($route);
$content = $repository->createNew();
$content->setTitle('Terms of Service');
$content->setBody($this->faker->text(350));
$content->addRoute($route);
$content->setParent($parent);
$content->setName('terms-of-service');
$manager->persist($content);
// Contact.
$route = $routeRepository->createNew();
$route->setPosition($routeRoot, 'about');
$manager->persist($route);
$content = $repository->createNew();
$content->setTitle('About us');
$content->setBody($this->faker->text(300));
$content->addRoute($route);
$content->setParent($parent);
$content->setName('about-us');
$manager->persist($content);
$manager->flush();
}
示例3: createNew
/**
* {@inheritdoc}
*/
public function createNew()
{
/** @var Route $route */
$route = $this->decoratedFactory->createNew();
$route->setParentDocument($this->documentManager->find(null, $this->routeParentPath));
return $route;
}
示例4: createNew
/**
* {@inheritdoc}
*/
public function createNew()
{
/** @var StaticContent $staticContent */
$staticContent = $this->decoratedFactory->createNew();
$staticContent->setParentDocument($this->documentManager->find(null, $this->staticContentParentPath));
return $staticContent;
}
示例5: verifyBrands
private function verifyBrands()
{
for ($i = 1; $i <= 10; ++$i) {
/* @var $brand \Hautelook\AliceBundle\Tests\SymfonyApp\TestBundle\Entity\Brand */
$this->doctrineManager->find('Hautelook\\AliceBundle\\Tests\\SymfonyApp\\TestBundle\\Entity\\Brand', $i);
}
}
示例6: load
/**
* Load data fixtures with the passed EntityManager
*
* @param ObjectManager $manager
*/
public function load(ObjectManager $manager)
{
$numOfertas = 5;
for ($i = 0; $i < $numOfertas; $i++) {
$oferta = new Oferta();
$oferta->setNombre("Oferta " . $i);
$oferta->setDescripcion("Descripción de la oferta " . $i);
$oferta->setCondiciones("Condiciones de la oferta " . $i);
$oferta->setFechaPublicacion(new \DateTime(date('Y-m-d H:i:s')));
$oferta->setFechaExpiracion(new \DateTime(date('Y-m-d H:i:s', strtotime('+1 years'))));
if ($i % 2) {
$oferta->setCiudad($manager->find('CiudadBundle:Ciudad', 1));
} else {
$oferta->setCiudad($manager->find('CiudadBundle:Ciudad', 2));
}
$oferta->setTienda($manager->find('TiendaBundle:Tienda', 1));
$oferta->setRutaFoto(null);
$oferta->setPrecio(19.99);
$oferta->setDescuento(0);
$oferta->setUmbral(100);
$oferta->setCompras(0);
$oferta->setRevisada(1);
$manager->persist($oferta);
}
$manager->flush();
}
示例7: loadUserByUsername
/**
* Loads the user for the given username.
*
* This method must throw UsernameNotFoundException if the user is not
* found.
*
* @param string $username The username
*
* @return UserInterface
*
* @see UsernameNotFoundException
*
* @throws UsernameNotFoundException if the user is not found
*
*/
public function loadUserByUsername($username)
{
if (!($user = $this->manager->find(null, sprintf('/users/%s', $username)))) {
throw new UsernameNotFoundException(sprintf('User "%s" not found', $username));
}
return $user;
}
示例8: load
public function load(ObjectManager $manager)
{
NodeHelper::createPath($manager->getPhpcrSession(), '/test');
NodeHelper::createPath($manager->getPhpcrSession(), '/test/content');
NodeHelper::createPath($manager->getPhpcrSession(), '/test/routes/content');
$contentRoot = $manager->find(null, '/test/content');
$routeRoot = $manager->find(null, '/test/routes/content');
$content = new SeoAwareContent();
$content->setName('content-1');
$content->setTitle('Content 1');
$content->setBody('Content 1');
$content->setParentDocument($contentRoot);
$metadata = new SeoMetadata();
$metadata->setTitle('Title content 1');
$metadata->setMetaDescription('Description of content 1.');
$metadata->setMetaKeywords('content1, content');
$metadata->setOriginalUrl('/to/original');
$content->setSeoMetadata($metadata);
$manager->persist($content);
$route = new Route();
$route->setPosition($routeRoot, 'content-1');
$route->setContent($content);
$route->setDefault('_controller', 'Symfony\\Cmf\\Bundle\\SeoBundle\\Tests\\Resources\\Controller\\TestController::indexAction');
$manager->persist($route);
$manager->persist($route);
$manager->flush();
}
示例9: save
/**
* @param object $object
* @param string $fieldName
* @param BaseControl $control
* @param IClassMetadata $classMetadata
* @throws \NForms\Exceptions\UnexpectedTypeException
* @return bool
*/
public function save($object, $fieldName, BaseControl $control, IClassMetadata $classMetadata)
{
if ($control->isOmitted() || $control->isDisabled()) {
return TRUE;
}
$value = $control->getValue();
if ($classMetadata->hasAssociation($fieldName) && $value !== NULL) {
if ($classMetadata->isSingleValuedAssociation($fieldName)) {
$value = $this->objectManager->find($classMetadata->getAssociationTargetClass($fieldName), $value);
} else {
if (!is_array($value) && (!$value instanceof \ArrayAccess || !$value instanceof \Iterator)) {
throw new UnexpectedTypeException("In mapping association {$classMetadata->getClass()}::\${$fieldName} - expected array or ArrayAccess and Iterator instance, given " . get_class($value) . ".");
}
$collection = array();
foreach ($value as $id) {
$collection[] = $this->objectManager->find($classMetadata->getAssociationTargetClass($fieldName), $id);
}
$value = $collection;
}
}
if ($classMetadata->hasAssociation($fieldName)) {
$classMetadata->setAssociationValue($object, $fieldName, $value);
} else {
if ($control instanceof Nette\Forms\Controls\TextBase && $value === '') {
$value = NULL;
}
$classMetadata->setFieldValue($object, $fieldName, $value);
}
return TRUE;
}
示例10: createWithCode
/**
* {@inheritdoc}
*/
public function createWithCode()
{
$organization = $this->decoratedFactory->createWithCode();
if ($organization instanceof HierarchyInterface) {
$organization->setParentDocument($this->documentManager->find(null, $this->rootPath));
}
return $organization;
}
示例11: getAttributeOption
/**
* Get an attribute option or throw an exception
*
* @param integer $id
*
* @throws EntityNotFoundException
*
* @return AttributeInterface
*/
public function getAttributeOption($id)
{
$attribute = $this->objectManager->find($this->getAttributeOptionClass(), $id);
if (null === $attribute) {
throw new EntityNotFoundException();
}
return $attribute;
}
示例12: load
/**
* Load the Document
*
* @param ObjectManager $manager
*/
public function load(ObjectManager $manager)
{
$description = new Description();
$description->setType($manager->find("Project\\Entity\\Idea\\DescriptionType", 1));
$description->setIdea($manager->find("Project\\Entity\\Idea\\Idea", 1));
$description->setDescription('This is the inital description');
$manager->persist($description);
$manager->flush();
}
示例13: load
public function load(ObjectManager $manager)
{
NodeHelper::createPath($manager->getPhpcrSession(), '/test/menus');
NodeHelper::createPath($manager->getPhpcrSession(), '/test/routes/contents');
$this->menuRoot = $manager->find(null, '/test/menus');
$this->routeRoot = $manager->find(null, '/test/routes');
$this->loadMenu($manager);
$manager->flush();
}
示例14: load
/**
* Load the Project
*
* @param ObjectManager $manager
*/
public function load(ObjectManager $manager)
{
$projectLogo = new Logo();
$projectLogo->setContentType($manager->find("General\\Entity\\ContentType", 1));
$projectLogo->setLogo(file_get_contents(__DIR__ . '/../../assets/img/project_logo.jpg'));
$projectLogo->setHires(file_get_contents(__DIR__ . '/../../assets/img/project_logo.jpg'));
$projectLogo->setProject($manager->find("Project\\Entity\\Project", 1));
$manager->persist($projectLogo);
$manager->flush();
}
示例15: load
public function load(ObjectManager $manager)
{
if ($manager->find('Api\\Camera\\Entity\\Camera', Camera::STATE_OFF) or $manager->find('Api\\Camera\\Entity\\Camera', Camera::STATE_ON)) {
return;
}
$camera = new Camera(Camera::STATE_OFF);
$manager->persist($camera);
$manager->flush();
echo __CLASS__, "\n";
}