Since: 2.2
Author: Fabien Potencier (fabien@symfony.com)
Author: Benjamin Eberlei (kontakt@beberlei.de)
Author: Lukas Kahwe Smith (smith@pooteeweet.org)
Inheritance: implements Doctrine\Common\Persistence\ManagerRegistry
示例#1
0
 /**
  * Construct AclFilter
  *
  * @param AbstractManagerRegistry  $doctrine
  * @param SecurityContextInterface $securityContext
  * @param array                    $options
  */
 public function __construct(AbstractManagerRegistry $doctrine, SecurityContextInterface $securityContext, array $options = array())
 {
     $this->em = $doctrine->getManager();
     $this->securityContext = $securityContext;
     $this->aclConnection = $doctrine->getConnection('default');
     list($this->aclWalker, $this->roleHierarchy) = $options;
 }
示例#2
0
 /**
  * @param ClassMetadata $classMetadata
  * @return \Doctrine\Common\Persistence\ObjectRepository
  */
 protected function getRepository(ClassMetadata $classMetadata)
 {
     $repository = $this->managerRegistry->getRepository($classMetadata->getName());
     if (!$repository instanceof ManagedRepositoryInterface) {
         return false;
     }
     return $repository;
 }
 /**
  * Persist block
  *
  * This block defines if entity must be persisted using desired
  * manager.
  *
  * This manager is defined as default in bundle parameters, but can
  * be overwritten in each annotation
  *
  * Same logic in perisist option. This variable is defined in bundle
  * parameters and can be overwritten there. Can also be defined in
  * every single annotation
  *
  * @param AnnotationEntity $annotation Annotation
  * @param Object           $entity     Entity
  *
  * @return EntityAnnotationResolver self Object
  */
 protected function resolvePersist(AnnotationEntity $annotation, $entity)
 {
     /**
      * Persist block
      *
      * This block defines if entity must be persisted using desired
      * manager.
      *
      * Given the entity we can find which manager manages it
      *
      * Same logic in perisist option. This variable is defined in bundle
      * parameters and can be overwritten there. Can also be defined in
      * every single annotation
      */
     /**
      * Get the persist variable. If not defined, is set as defined in
      * parameters
      */
     $persist = !is_null($annotation->getPersist()) ? $annotation->getPersist() : $this->defaultPersist;
     if ($persist) {
         /**
          * Loading locally desired Doctrine manager
          */
         $this->doctrine->getManagerForClass(get_class($entity))->persist($entity);
     }
     return $this;
 }
 /**
  * Specific annotation evaluation.
  *
  * @param Request          $request    Request
  * @param Annotation       $annotation Annotation
  * @param ReflectionMethod $method     Method
  *
  * @return EntityAnnotationResolver self Object
  *
  * @throws EntityNotFoundException
  */
 public function evaluateAnnotation(Request $request, Annotation $annotation, ReflectionMethod $method)
 {
     /**
      * Annotation is only laoded if is typeof AnnotationEntity
      */
     if ($annotation instanceof AnnotationObjectManager) {
         /**
          * Creating new instance of desired entity
          */
         $entity = $this->entityProvider->provide($annotation->getClass());
         $objectManager = $this->doctrine->getManagerForClass(get_class($entity));
         /**
          * Get the parameter name. If not defined, is set as defined in
          * parameters
          */
         $parameterName = $annotation->getName() ?: $this->defaultName;
         $request->attributes->set($parameterName, $objectManager);
     }
     return $this;
 }
示例#5
0
 public function __construct(array $connections, array $managers, $defaultConnection, $defaultManager, Nette\DI\Container $serviceLocator)
 {
     parent::__construct('ORM', $connections, $managers, $defaultConnection, $defaultManager, 'Doctrine\\ORM\\Proxy\\Proxy');
     $this->serviceLocator = $serviceLocator;
 }
 /**
  * Generate QueryBuilder
  *
  * @param Object $entity Entity instance
  *
  * @return QueryBuilder Query builder
  */
 public function createQueryBuilder($entity)
 {
     $entityNamespace = get_class($entity);
     return $this->doctrine->getManagerForClass(get_class($entity))->createQueryBuilder()->select(array('x'))->from($entityNamespace, 'x');
 }
示例#7
0
 /**
  * Constructor.
  *
  * @param Container $app                A Container instance
  * @param string    $proxyInterfaceName The proxy interface name
  */
 public function __construct(Container $app, $proxyInterfaceName = 'Doctrine\\ORM\\Proxy\\Proxy')
 {
     $this->app = $app;
     parent::__construct(null, [], ['default' => 'orm.em'], null, 'default', $proxyInterfaceName);
 }
示例#8
0
 public function __construct(Application $app, $name, array $connections, array $managers, $defaultConnection, $defaultManager, $proxyInterfaceName)
 {
     $this->app = $app;
     parent::__construct($name, $connections, $managers, $defaultConnection, $defaultManager, $proxyInterfaceName);
 }
 public function __construct($serviceCreator, $name = 'anonymous', array $connections = array('default' => 'default_connection'), array $managers = array('default' => 'default_manager'), $defaultConnection = null, $defaultManager = null, $proxyInterface = 'Doctrine\\Common\\Persistence\\Proxy')
 {
     if (null === $defaultConnection) {
         list($defaultConnection, ) = each($connections);
     }
     if (null === $defaultManager) {
         list($defaultManager, ) = each($managers);
     }
     parent::__construct($name, $connections, $managers, $defaultConnection, $defaultManager, $proxyInterface);
     if (!is_callable($serviceCreator)) {
         throw new \InvalidArgumentException('$serviceCreator must be a valid callable.');
     }
     $this->serviceCreator = $serviceCreator;
 }
示例#10
0
 public function __construct(EntityManager $em)
 {
     parent::__construct(null, [], ['em' => 'em'], null, 'em', Proxy::class);
     $this->services = new ArrayCollection();
     $this->addService('em', $em);
 }
 /**
  * @param Container $container
  * @param array     $connections
  * @param array     $entityManagers
  * @param string    $defaultConnection
  * @param string    $defaultEntityManager
  */
 public function __construct(Container $container, array $connections, array $entityManagers, $defaultConnection, $defaultEntityManager)
 {
     $this->setContainer($container);
     parent::__construct('ORM', $connections, $entityManagers, $defaultConnection, $defaultEntityManager, 'Doctrine\\ORM\\Proxy\\Proxy');
 }
 /**
  * Constructor.
  *
  * @param string $name
  * @param array  $connections
  * @param array  $managers
  * @param string $defaultConnection
  * @param string $defaultManager
  * @param string $proxyInterfaceName
  * @param ServiceManager $serviceManager
  */
 public function __construct($name, array $connections, array $managers, $defaultConnection, $defaultManager, $proxyInterfaceName, ServiceManager $serviceManager)
 {
     parent::__construct($name, $connections, $managers, $defaultConnection, $defaultManager, $proxyInterfaceName);
     $this->serviceManager = $serviceManager;
 }
示例#13
0
 /**
  * Given an entity namespace, return associated object Manager.
  *
  * @param string $entityNamespace Entity Namespace
  *
  * @return ObjectManager|null Object manager
  */
 public function getManagerByEntityNamespace($entityNamespace)
 {
     return $this->manager->getManagerForClass($entityNamespace);
 }
示例#14
0
 public function __construct($c, $name, array $connections, array $managers, $defaultConnection, $defaultManager, $proxyInterfaceName)
 {
     $this->c = $c;
     parent::__construct($name, $connections, $managers, $defaultConnection, $defaultManager, $proxyInterfaceName);
 }