partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

BaseConfiguration.php (2287B)


      1 <?php
      2 
      3 namespace PartKeepr\ImportBundle\Configuration;
      4 
      5 use Doctrine\Common\Persistence\Mapping\ClassMetadata;
      6 use Doctrine\ORM\EntityManager;
      7 use Dunglas\ApiBundle\Api\IriConverter;
      8 use PartKeepr\DoctrineReflectionBundle\Filter\AdvancedSearchFilter;
      9 use PartKeepr\DoctrineReflectionBundle\Services\ReflectionService;
     10 
     11 class BaseConfiguration
     12 {
     13     public static $logs = [];
     14     public static $persistEntities = [];
     15     protected $baseEntity;
     16     protected $classMetadata;
     17     protected $reflectionService;
     18     protected $em;
     19     protected $advancedSearchFilter;
     20     protected $iriConverter;
     21     private $path = [];
     22 
     23     public function __construct(
     24         ClassMetadata $classMetadata,
     25         $baseEntity,
     26         ReflectionService $reflectionService,
     27         EntityManager $em,
     28         AdvancedSearchFilter $advancedSearchFilter,
     29         IriConverter $iriConverter
     30     ) {
     31         $this->classMetadata = $classMetadata;
     32         $this->baseEntity = $baseEntity;
     33         $this->reflectionService = $reflectionService;
     34         $this->em = $em;
     35         $this->advancedSearchFilter = $advancedSearchFilter;
     36         $this->iriConverter = $iriConverter;
     37     }
     38 
     39     /**
     40      * Returns the path of this configuration node with an optional suffix.
     41      *
     42      * @param bool|string $suffix Set to any string to return an additional suffix, or false to skip
     43      *
     44      * @return array The individual path components
     45      */
     46     public function getPath($suffix = false)
     47     {
     48         if ($suffix !== false) {
     49             $path = $this->path;
     50             $path[] = $suffix;
     51 
     52             return $path;
     53         } else {
     54             return $this->path;
     55         }
     56     }
     57 
     58     /**
     59      * Sets a path for this configuration node.
     60      *
     61      * @param array $path
     62      */
     63     public function setPath($path)
     64     {
     65         $this->path = $path;
     66     }
     67 
     68     public function import($row)
     69     {
     70     }
     71 
     72     public function persist($entity)
     73     {
     74         self::$persistEntities[] = $entity;
     75     }
     76 
     77     public function getPersistEntities()
     78     {
     79         return self::$persistEntities;
     80     }
     81 
     82     public function log($message)
     83     {
     84         self::$logs[] = $message;
     85     }
     86 
     87     public function getLog()
     88     {
     89         return self::$logs;
     90     }
     91 
     92     public function clearLog()
     93     {
     94         self::$logs = [];
     95     }
     96 }