コード例 #1
0
 /**
  * Test setting all cache types to true
  *
  * Fixture is the same as in previous test, but here the intent to disable all of them.
  * Since only one of them is enabled, the setter should be invoked only once.
  * Also the operation of deactivating cache does not need cleanup (it is relevant when you enable it).
  */
 public function testSetEnabledFalseAll()
 {
     $caches = ['foo', 'bar', 'baz'];
     $cacheStatusMap = [['foo', true], ['bar', false], ['baz', false]];
     $this->cacheState->expects($this->exactly(3))->method('isEnabled')->will($this->returnValueMap($cacheStatusMap));
     $this->cacheState->expects($this->once())->method('setEnabled')->with('foo', false);
     $this->cacheState->expects($this->once())->method('persist');
     $this->frontendPool->expects($this->never())->method('get');
     $this->assertEquals(['foo'], $this->model->setEnabled($caches, false));
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  * @return Response
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function launch()
 {
     $output = [];
     $types = $this->getRequestedTypes();
     $enabledTypes = [];
     if (isset($this->requestArgs[self::KEY_SET])) {
         $isEnabled = (bool) (int) $this->requestArgs[self::KEY_SET];
         $changedTypes = $this->cacheManager->setEnabled($types, $isEnabled);
         if ($isEnabled) {
             $enabledTypes = $changedTypes;
         }
         if ($changedTypes) {
             $output[] = 'Changed cache status:';
             foreach ($changedTypes as $type) {
                 $output[] = sprintf('%30s: %d -> %d', $type, !$isEnabled, $isEnabled);
             }
         } else {
             $output[] = 'There is nothing to change in cache status';
         }
     }
     if (isset($this->requestArgs[self::KEY_FLUSH])) {
         $this->cacheManager->flush($types);
         $output[] = 'Flushed cache types:';
         $output[] = join("\n", $types);
     } elseif (isset($this->requestArgs[self::KEY_CLEAN])) {
         $this->cacheManager->clean($types);
         $output[] = 'Cleaned cache types:';
         $output[] = join("\n", $types);
     } elseif (isset($this->requestArgs[self::KEY_STATUS])) {
         $output[] = 'Current status:';
         foreach ($this->cacheManager->getStatus() as $cache => $status) {
             $output[] = sprintf('%30s: %d', $cache, $status);
         }
     } elseif (!empty($enabledTypes)) {
         $this->cacheManager->clean($enabledTypes);
         $output[] = 'Cleaned cache types:';
         $output[] = join("\n", $enabledTypes);
     }
     $output[] = '';
     $this->response->setBody(join("\n", $output));
     return $this->response;
 }
コード例 #3
0
 /**
  * Returns plugin list:
  * ['concrete class name' => ['plugin name' => [instance => 'instance name', 'order' => 'Order Number']]]
  *
  * @param array $interceptedInstances
  * @return array
  */
 private function getPluginsList($interceptedInstances)
 {
     $this->cacheManager->setEnabled([CompiledConfig::TYPE_IDENTIFIER], true);
     $this->pluginList->setInterceptedClasses($interceptedInstances);
     $inheritedConfig = [];
     foreach ($this->areaCodesList as $areaKey) {
         $scopePriority = [Area::AREA_GLOBAL];
         $pluginListCloned = clone $this->pluginList;
         if ($areaKey != Area::AREA_GLOBAL) {
             $scopePriority[] = $areaKey;
             $pluginListCloned->setScopePriorityScheme($scopePriority);
         }
         $key = implode('', $scopePriority);
         $inheritedConfig[$key] = $this->filterNullInheritance($pluginListCloned->getPluginsConfig());
     }
     return $inheritedConfig;
 }