/**
  * Handle the create entity event.
  *
  * @param CreateEntityRepositoryEvent $event The received event.
  *
  * @return void
  */
 public function handleCreateEntityRepository(CreateEntityRepositoryEvent $event)
 {
     if ($event->getRepository()) {
         return;
     }
     $providerName = $event->getProviderName();
     $driver = $this->getDriver($providerName);
     switch ($driver) {
         case 'Table':
             $provider = new DefaultDataProvider();
             $provider->setBaseConfig(array('source' => $providerName));
             break;
         case 'General':
             // @codingStandardsIgnoreStart
             // TODO: Handle DcGeneral
             // @codingStandardsIgnoreEnd
         // @codingStandardsIgnoreStart
         // TODO: Handle DcGeneral
         // @codingStandardsIgnoreEnd
         default:
             return;
     }
     $repository = new EntityRepository($provider);
     $event->setRepository($repository);
 }
 /**
  * Callback listener for get node items.
  *
  * @return null|string
  */
 public function getItems()
 {
     if ($this->node['type'] !== 'regular') {
         return null;
     }
     $dataProvider = new DefaultDataProvider();
     $dataProvider->setBaseConfig(array('source' => 'tl_article'));
     $count = $dataProvider->getCount($dataProvider->getEmptyConfig()->setFilter(array(array('property' => 'pid', 'value' => $this->node['id'], 'operation' => '='))));
     if (intval($count) <= 0) {
         return null;
     }
     return $this->getArticleNode($this->node['id']);
 }
Ejemplo n.º 3
0
 /**
  * Test that setting the base config works.
  *
  * @return void
  */
 public function testSetBaseConfig()
 {
     $database = $this->mockDatabase();
     $database->method('list_fields')->willReturn(array(array('name' => 'idField', 'type' => 'field'), array('name' => 'lastChanged', 'type' => 'field'), array('name' => 'idField', 'type' => 'index')));
     $idGenerator = $this->getMockForAbstractClass('ContaoCommunityAlliance\\DcGeneral\\Data\\IdGeneratorInterface');
     $dataProvider = new DefaultDataProvider();
     $dataProvider->setBaseConfig(array('source' => 'tl_something', 'database' => $database, 'idProperty' => 'idField', 'timeStampProperty' => 'lastChanged', 'idGenerator' => $idGenerator));
     $reflection = new \ReflectionProperty('ContaoCommunityAlliance\\DcGeneral\\Data\\DefaultDataProvider', 'objDatabase');
     $reflection->setAccessible(true);
     $this->assertEquals('tl_something', $dataProvider->getEmptyModel()->getProviderName());
     $this->assertEquals($database, $reflection->getValue($dataProvider));
     $this->assertEquals('idField', $dataProvider->getIdProperty());
     $this->assertEquals('lastChanged', $dataProvider->getTimeStampProperty());
     $this->assertSame($idGenerator, $dataProvider->getIdGenerator());
 }
 /**
  * Set base config with source and other necessary parameter.
  *
  * @param array $arrConfig The configuration to use.
  *
  * @return void
  *
  * @throws DcGeneralException When no source has been defined.
  */
 public function setBaseConfig(array $arrConfig)
 {
     parent::setBaseConfig($arrConfig);
     if (!$arrConfig['group_column']) {
         throw new DcGeneralException('ContaoCommunityAlliance\\DcGeneral\\Data\\TableRowsAsRecordsDriver needs a grouping column.', 1);
     }
     $this->strGroupCol = $arrConfig['group_column'];
     if ($arrConfig['sort_column']) {
         $this->strSortCol = $arrConfig['sort_column'];
     }
 }
 /**
  * check if calendar is empty.
  *
  * @param $node
  *
  * @return bool
  */
 protected function isEmptyCalendar($node)
 {
     $dataProvider = new DefaultDataProvider();
     $dataProvider->setBaseConfig(array('source' => 'tl_calendar_events'));
     $count = $dataProvider->getCount($dataProvider->getEmptyConfig()->setFilter(array(array('property' => 'pid', 'value' => $node['id'], 'operation' => '='))));
     if (intval($count) <= 0) {
         return true;
     }
     return false;
 }