當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectManager::find方法代碼示例

本文整理匯總了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();
 }
開發者ID:ElectricMaxxx,項目名稱:ipc-cmf-example-application,代碼行數:33,代碼來源:LoadSeoContent.php

示例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();
 }
開發者ID:Strontium-90,項目名稱:Sylius,代碼行數:38,代碼來源:LoadPagesData.php

示例3: createNew

 /**
  * {@inheritdoc}
  */
 public function createNew()
 {
     /** @var Route $route */
     $route = $this->decoratedFactory->createNew();
     $route->setParentDocument($this->documentManager->find(null, $this->routeParentPath));
     return $route;
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:10,代碼來源:RouteFactory.php

示例4: createNew

 /**
  * {@inheritdoc}
  */
 public function createNew()
 {
     /** @var StaticContent $staticContent */
     $staticContent = $this->decoratedFactory->createNew();
     $staticContent->setParentDocument($this->documentManager->find(null, $this->staticContentParentPath));
     return $staticContent;
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:10,代碼來源:StaticContentFactory.php

示例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);
     }
 }
開發者ID:Vowow,項目名稱:AliceBundle,代碼行數:7,代碼來源:DoctrineFixtureTest.php

示例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();
 }
開發者ID:aique,項目名稱:cupon,代碼行數:31,代碼來源:Ofertas.php

示例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;
 }
開發者ID:Cohros,項目名稱:KnowledgeBase,代碼行數:22,代碼來源:UserProvider.php

示例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();
 }
開發者ID:symfony-cmf,項目名稱:sonata-admin-integration-bundle,代碼行數:27,代碼來源:LoadContentData.php

示例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;
 }
開發者ID:mike227,項目名稱:n-forms,代碼行數:38,代碼來源:ControlMapper.php

示例10: createWithCode

 /**
  * {@inheritdoc}
  */
 public function createWithCode()
 {
     $organization = $this->decoratedFactory->createWithCode();
     if ($organization instanceof HierarchyInterface) {
         $organization->setParentDocument($this->documentManager->find(null, $this->rootPath));
     }
     return $organization;
 }
開發者ID:SuperdeskWebPublisher,項目名稱:SWPMultiTenancyBundle,代碼行數:11,代碼來源:OrganizationFactory.php

示例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;
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:17,代碼來源:AttributeOptionManager.php

示例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();
 }
開發者ID:debranova,項目名稱:project,代碼行數:14,代碼來源:LoadIdeaDescriptionData.php

示例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();
 }
開發者ID:frogriotcom,項目名稱:MenuBundle,代碼行數:9,代碼來源:LoadMenuData.php

示例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();
 }
開發者ID:debranova,項目名稱:project,代碼行數:15,代碼來源:LoadProjectLogoData.php

示例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";
 }
開發者ID:phprest,項目名稱:phprest-api-blueprint-sample-project,代碼行數:10,代碼來源:StateToOff.php


注:本文中的Doctrine\Common\Persistence\ObjectManager::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。