public function testSetPrefix()
 {
     $builder = new ServiceIdBuilder();
     $this->assertSame('config', $builder->getPrefix());
     $builder->setPrefix($expected = 'zzz');
     $this->assertSame($expected, $builder->getPrefix());
 }
Ejemplo n.º 2
0
 /**
  * Validates a cache ID.
  *
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  *
  * @throws \Exception Throws if the cacheId and a bundle name are duplicated.
  */
 protected function validateCacheId()
 {
     foreach ($this->container->getParameter('kernel.bundles') as $className => $fqcn) {
         $id = ServiceIdBuilder::parseServiceId($className);
         $serviceIdPrefix = $this->idBuilder->getPrefix();
         if ($serviceIdPrefix === $id) {
             throw new \Exception("Cache ID[{$serviceIdPrefix}] and Service ID[{$id}] " . "based Bundle name[{$className}] are duplicated");
         }
     }
 }
 protected function getCacheId()
 {
     if (is_null($this->cacheId)) {
         $builder = new ServiceIdBuilder();
         $this->cacheId = $builder->getPrefix();
     }
     return $this->cacheId;
 }