public function testSlugHandlerMapping() { $meta = $this->em->getClassMetadata(self::SLUGGABLE); $cacheId = ExtensionMetadataFactory::getCacheId(self::SLUGGABLE, 'Gedmo\\Sluggable'); $config = $this->em->getMetadataFactory()->getCacheDriver()->fetch($cacheId); $this->assertArrayHasKey('handlers', $config); $handlers = $config['handlers']; $this->assertEquals(2, count($handlers)); $this->assertArrayHasKey('Gedmo\\Sluggable\\Handler\\TreeSlugHandler', $handlers); $this->assertArrayHasKey('Gedmo\\Sluggable\\Handler\\RelativeSlugHandler', $handlers); $first = $handlers['Gedmo\\Sluggable\\Handler\\TreeSlugHandler']; $this->assertEquals(2, count($first)); $this->assertArrayHasKey('parentRelationField', $first); $this->assertArrayHasKey('separator', $first); $this->assertEquals('parent', $first['parentRelationField']); $this->assertEquals('/', $first['separator']); $second = $handlers['Gedmo\\Sluggable\\Handler\\RelativeSlugHandler']; $this->assertEquals(3, count($second)); $this->assertArrayHasKey('relationField', $second); $this->assertArrayHasKey('relationSlugField', $second); $this->assertArrayHasKey('separator', $second); $this->assertEquals('user', $second['relationField']); $this->assertEquals('slug', $second['relationSlugField']); $this->assertEquals('/', $second['separator']); }
public function testLoggableMapping() { $meta = $this->em->getClassMetadata(self::YAML_CATEGORY); $cacheId = ExtensionMetadataFactory::getCacheId(self::YAML_CATEGORY, 'Gedmo\\Loggable'); $config = $this->em->getMetadataFactory()->getCacheDriver()->fetch($cacheId); $this->assertArrayHasKey('loggable', $config); $this->assertTrue($config['loggable']); $this->assertArrayHasKey('logEntryClass', $config); $this->assertEquals('Gedmo\\Loggable\\Entity\\LogEntry', $config['logEntryClass']); }
public function testYamlClosureMapping() { $meta = $this->em->getClassMetadata(self::YAML_CLOSURE_CATEGORY); $cacheId = ExtensionMetadataFactory::getCacheId(self::YAML_CLOSURE_CATEGORY, 'Gedmo\\Tree'); $config = $this->em->getMetadataFactory()->getCacheDriver()->fetch($cacheId); $this->assertArrayHasKey('parent', $config); $this->assertEquals('parent', $config['parent']); $this->assertArrayHasKey('strategy', $config); $this->assertEquals('closure', $config['strategy']); $this->assertArrayHasKey('closure', $config); $this->assertEquals('Tree\\Fixture\\Closure\\CategoryClosure', $config['closure']); }
public function testYamlMapping() { $meta = $this->em->getClassMetadata(self::TEST_YAML_ENTITY_CLASS); $cacheId = ExtensionMetadataFactory::getCacheId(self::TEST_YAML_ENTITY_CLASS, 'Gedmo\\Translatable'); $config = $this->em->getMetadataFactory()->getCacheDriver()->fetch($cacheId); $this->assertArrayHasKey('translationClass', $config); $this->assertEquals('Translatable\\Fixture\\PersonTranslation', $config['translationClass']); $this->assertArrayHasKey('fields', $config); $this->assertCount(2, $config['fields']); $this->assertEquals('password', $config['fields'][0]); $this->assertEquals('username', $config['fields'][1]); $this->assertArrayHasKey('locale', $config); $this->assertEquals('localeField', $config['locale']); }
public function testYamlMapping() { $meta = $this->em->getClassMetadata(self::TEST_YAML_ENTITY_CLASS); $cacheId = ExtensionMetadataFactory::getCacheId(self::TEST_YAML_ENTITY_CLASS, 'Gedmo\\Timestampable'); $config = $this->em->getMetadataFactory()->getCacheDriver()->fetch($cacheId); $this->assertArrayHasKey('create', $config); $this->assertEquals('created', $config['create'][0]); $this->assertArrayHasKey('update', $config); $this->assertEquals('updated', $config['update'][0]); $this->assertArrayHasKey('change', $config); $onChange = $config['change'][0]; $this->assertEquals('changed', $onChange['field']); $this->assertEquals('title', $onChange['trackedField']); $this->assertEquals('Test', $onChange['value']); }
/** * Get the configuration for specific entity class * if cache driver is present it scans it also * * @param EntityManager $em * @param string $class * @return array */ public function getConfiguration(EntityManager $em, $class) { $config = array(); if (isset($this->_configurations[$class])) { $config = $this->_configurations[$class]; } else { $cacheDriver = $em->getMetadataFactory()->getCacheDriver(); $cacheId = ExtensionMetadataFactory::getCacheId($class, __NAMESPACE__); if (($cached = $cacheDriver->fetch($cacheId)) !== false) { $this->_configurations[$class] = $cached; $config = $cached; } } return $config; }
public function testYamlClosureMapping() { if (!extension_loaded('apc') || !ini_get('apc.enable_cli')) { $this->markTestSkipped('APC extension is not loaded.'); } $meta = $this->em->getClassMetadata(self::YAML_CLOSURE_CATEGORY); $cacheId = ExtensionMetadataFactory::getCacheId(self::YAML_CLOSURE_CATEGORY, 'Gedmo\\Tree'); $config = $this->em->getMetadataFactory()->getCacheDriver()->fetch($cacheId); $this->assertArrayHasKey('parent', $config); $this->assertEquals('parent', $config['parent']); $this->assertArrayHasKey('strategy', $config); $this->assertEquals('closure', $config['strategy']); $this->assertArrayHasKey('closure', $config); $this->assertEquals('Tree\\Fixture\\Closure\\CategoryClosure', $config['closure']); }
public function testYamlMapping() { $meta = $this->em->getClassMetadata(self::TEST_YAML_ENTITY_CLASS); $cacheId = ExtensionMetadataFactory::getCacheId(self::TEST_YAML_ENTITY_CLASS, 'Gedmo\\Sluggable'); $config = $this->em->getMetadataFactory()->getCacheDriver()->fetch($cacheId); $this->assertArrayHasKey('slug', $config); $this->assertEquals('slug', $config['slug']); $this->assertArrayHasKey('fields', $config); $this->assertEquals(1, count($config['fields'])); $this->assertEquals('title', $config['fields'][0]['field']); $this->assertArrayHasKey('style', $config); $this->assertEquals('camel', $config['style']); $this->assertArrayHasKey('separator', $config); $this->assertEquals('_', $config['separator']); $this->assertArrayHasKey('unique', $config); $this->assertTrue($config['unique']); $this->assertArrayHasKey('updatable', $config); $this->assertTrue($config['updatable']); }
/** * Get the configuration for specific object class * if cache driver is present it scans it also * * @param ObjectManager $objectManager * @param string $class * @return array */ public function getConfiguration(ObjectManager $objectManager, $class) { $config = array(); if (isset($this->configurations[$class])) { $config = $this->configurations[$class]; } else { $cacheDriver = $objectManager->getMetadataFactory()->getCacheDriver(); $cacheId = ExtensionMetadataFactory::getCacheId($class, $this->getNamespace()); if ($cacheDriver && ($cached = $cacheDriver->fetch($cacheId)) !== false) { $this->configurations[$class] = $cached; $config = $cached; } } return $config; }
/** * Get the configuration for specific object class * if cache driver is present it scans it also * * @param ObjectManager $objectManager * @param string $class * @return array */ public function getConfiguration(ObjectManager $objectManager, $class) { $config = array(); if (isset(self::$configurations[$this->name][$class])) { $config = self::$configurations[$this->name][$class]; } else { $factory = $objectManager->getMetadataFactory(); $cacheDriver = $factory->getCacheDriver(); if ($cacheDriver) { $cacheId = ExtensionMetadataFactory::getCacheId($class, $this->getNamespace()); if (($cached = $cacheDriver->fetch($cacheId)) !== false) { self::$configurations[$this->name][$class] = $cached; $config = $cached; } else { // re-generate metadata on cache miss $this->loadMetadataForObjectClass($objectManager, $factory->getMetadataFor($class)); if (isset(self::$configurations[$this->name][$class])) { $config = self::$configurations[$this->name][$class]; } } } } return $config; }
/** * Generally loads configuration from cache * * @throws RuntimeException if no configuration for class found * @return array */ public function getConfiguration() { $config = array(); if (isset($this->_configurations[$this->_entityName])) { $config = $this->_configurations[$this->_entityName]; } else { $cacheDriver = $this->_em->getMetadataFactory()->getCacheDriver(); $cacheId = \Gedmo\Mapping\ExtensionMetadataFactory::getCacheId($this->_entityName, 'Gedmo\\Tree'); if (($cached = $cacheDriver->fetch($cacheId)) !== false) { $this->_configurations[$this->_entityName] = $cached; $config = $cached; } } if (!$config) { throw new \RuntimeException("TreeNodeRepository: this repository cannot be used on {$this->_entityName} without Tree metadata"); } return $config; }