Skip to content
Snippets Groups Projects
Select Git revision
  • ec701c1679f39e62e30a9981a4c7f6a077db47dc
  • master default protected
  • release_3.0.0
  • test
  • feature_pre_sql
  • develop
  • 3.0.1
  • 3.0.0
  • 2.3.0
  • 2.2.0
  • 2.1.0
  • 2.0.0
  • 1.3.7
  • 1.3.6
  • 1.3.5
  • 1.3.4
  • 1.3.3
  • 1.3.2
  • 1.3.1
  • 1.3.0
  • 1.2.6
  • 1.2.5
  • 1.2.4
  • 1.2.3
  • 1.2.2
  • 1.2.1
26 results

development.config.php.dist

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    HydratorAwareTrait.php 1.23 KiB
    <?php
    
    namespace <namespace>;
    
    use <targetFullClass>;
    use Application\Module;
    use RuntimeException;
    
    /**
     * Description of <class>
     *
     * @author UnicaenCode
     */
    trait <class>
    {
        /**
         * @var <targetClass>
         */
        private $<variable>;
    
    
    
    
    
        /**
         * @param <targetClass> $<variable>
         * @return self
         */
        public function set<method>( <targetClass> $<variable> )
        {
            $this-><variable> = $<variable>;
            return $this;
        }
    
    
    
        /**
         * @return <targetClass>
         * @throws RuntimeException
         */
        public function get<method>()
        {
            if (empty($this-><variable>)){
            $serviceLocator = Module::$serviceLocator;
            if (! $serviceLocator) {
                if (!method_exists($this, 'getServiceLocator')) {
                    throw new RuntimeException('La classe ' . get_class($this) . ' n\'a pas accès au ServiceLocator.');
                }
    
                $serviceLocator = $this->getServiceLocator();
                if (method_exists($serviceLocator, 'getServiceLocator')) {
                    $serviceLocator = $serviceLocator->getServiceLocator();
                }
            }
            $this-><variable> = $serviceLocator->get('HydratorManager')->get('<name>');
            }
            return $this-><variable>;
        }
    }