/** * Get result from cache or execute database query * * @param array $config query and cache parameters * @param ServiceLocatorInterface $sl * @return multitype:NULL */ protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { $worker = new Worker($sl->get($config['entitymanager'])); $worker->setEntity($config['entity']); $entries = $worker->getStorage()->getRepository($worker->getEntityName())->findBy(array('publish' => 'yes'), array('itemRang' => 'ASC')); $i = 1; foreach ($entries as $entry) { $metas = array(); $metas['rel'] = $entry->metaRel ? $entry->metaRel : false; $metas['type'] = $entry->metaType ? $entry->metaType : false; $metas['title'] = $entry->metaTitle ? $entry->metaTitle : false; $metas['content'] = $entry->metaContent ? $entry->metaContent : false; if (1 !== $entry->webMedias->id) { $metas['href'] = $entry->webMedias->mediaLink; $metas['sizes'] = $entry->webMedias->mediaDimensions; } else { $metas['href'] = $entry->metaLink; } $result[$entry->webPages->id][] = $metas; $i++; } if (isset($config['savecache']) && true === $config['savecache']) { $cache->setItem($key, $result); } } if (null === $result) { $result = array(); } return $result; }
public function createService(ServiceLocatorInterface $serviceLocator) { $realServiceLocator = $serviceLocator->getServiceLocator(); $postService = $realServiceLocator->get('Blog\\Service\\PostServiceInterface'); $postInsertForm = $realServiceLocator->get('FormElementManager')->get('Blog\\Form\\PostForm'); return new WriteController($postService, $postInsertForm); }
/** * Get result from cache or read from php file * * @param string $file path to file and filename * @param string $key template file ident * @param ServiceLocatorInterface $sl */ protected function getFileAsConfig($files, $key, $sl) { $cache = $sl->get(static::CONTENTINUM_CACHE); if (!($result = $cache->getItem($key))) { $plugins = array(); foreach ($files as $file) { if (empty($plugins)) { $plugins = (include $file); } else { $plugins = array_merge_recursive($plugins, include $file); } } $plugins = $plugins['default_plugins']; ksort($plugins); foreach ($plugins as $k => $rows) { foreach ($rows as $plugin => $row) { $result[$plugin] = $row; } } //print '<pre>'; //var_dump($result); //exit; $result = new Config($result); $cache->setItem($key, $result); } return $result; }
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config_authentification_form'); $factory = new Factory(); $form = $factory->createForm($config); return $form; }
/** * Get cache keys * * @param ServiceLocatorInterface $sl * @return array */ protected function getCacheKeys($sl) { if (false === $this->keys) { $keys = $sl->get(self::MCWORK_CACHEKEYS); $this->keys = $keys->toArray(); } return $this->keys; }
public function testStrongEncryptAndDecryptWithProvidedKey() { $testString = 'Hello World !'; $testkey = '123456789abcdef'; $this->serviceLocator->expects($this->at(0))->method('get')->with('config')->willReturn($this->config); $service = $this->factory->createService($this->serviceLocator); $encryptedString = $service->encrypt($testString, $testkey); $decryptedString = $service->decrypt($encryptedString, $testkey); $this->assertEquals($testString, $decryptedString); }
/** * Get result from cache or read from php file * * @param string $file path to file and filename * @param string $key template file ident * @param ServiceLocatorInterface $sl */ protected function getFileAsConfig($file, $key, $sl) { $cache = $sl->get(static::CONTENTINUM_CACHE); if (!($result = $cache->getItem($key))) { $result = new Config(include $file); if (is_file(CON_ROOT_PATH . '/data/opt/customer.config.php')) { $result->merge(new Config(include CON_ROOT_PATH . '/data/opt/customer.config.php')); } $cache->setItem($key, $result); } return $result; }
/** * Get result from cache or read from php file * * @param string $file path to file and filename * @param string $key template file ident * @param ServiceLocatorInterface $sl */ protected function getFileAsConfig($file, $key, $sl) { $cache = $sl->get(static::CONTENTINUM_CACHE); if (!($result = $cache->getItem($key))) { $i = 1; foreach ($file as $singleFile) { if (1 === $i) { $result = new Config(include $singleFile); } else { $result->merge(new Config(include $singleFile)); } $i++; } $cache->setItem($key, $result); } return $result; }
/** * Get result from cache or read from php file * * @param string $file path to file and filename * @param string $key template file ident * @param ServiceLocatorInterface $sl */ protected function getFileAsConfig($files, $key, $sl) { $cache = $sl->get(static::CONTENTINUM_CACHE); if (!($result = $cache->getItem('viewhelper_plugins'))) { $plugins = array(); foreach ($files as $file) { if (empty($plugins)) { $plugins = (include $file); } else { $plugins = array_merge_recursive($plugins, include $file); } } $result = new Config($plugins['viewhelper_plugins']); $cache->setItem('viewhelper_plugins', $result); } return $result; }
/** * Get result from cache or read from php file * * @param string $file path to file and filename * @param string $key template file ident * @param ServiceLocatorInterface $sl */ protected function getFileAsConfig($dir, $key, $sl) { $cache = $sl->get(static::CONTENTINUM_CACHE); if (!($result = $cache->getItem($key))) { $i = 1; foreach (scandir($dir) as $file) { if ('.' != $file && '..' != $file) { if (1 === $i) { $result = new Config(include $dir . DS . $file); } else { $result->merge(new Config(include $dir . DS . $file)); } $i++; } } $cache->setItem($key, $result); } return $result; }
/** * Get result from cache or read from php file * * @param string $file * path to file and filename * @param string $key * template file ident * @param ServiceLocatorInterface $sl */ protected function getFileAsConfig($files, $key, $sl) { $cache = $sl->get(static::CONTENTINUM_CACHE); if (!($result = $cache->getItem($key))) { if (isset($files['Mcwork'])) { $navigations = (include $files['Mcwork']); unset($files['Mcwork']); $navigations = array_merge_recursive($navigations, include $files['Mcuser']); unset($files['Mcuser']); $result = new Config($navigations, true); } $apps = array(); foreach ($files as $file) { $apps = array_merge_recursive($apps, include $file); } foreach ($result->navigation->default as $entry) { if ('Contentinum_Apps' == $entry->label) { $entry->pages = $apps['pages']; } } $cache->setItem($key, $result); } return $result; }
/** * Get a configuration file. * * @param string $config Configuration name * * @return \Zend\Config\Config */ public static function getConfig($config = 'config') { return static::$serviceLocator->get('VuFind\\Config')->get($config); }
/** * Mock the service locator */ public function setUpServiceLocator() { $config = $this->getConfig(); $this->serviceLocatorInterface = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface', array('get')); $this->serviceLocatorInterface->expects($this->any())->method('get')->will($this->returnValue($config)); }
public function addCancelField() { $url = $this->serviceLocator->get('viewhelpermanager')->get('url'); $this->add(array('name' => 'cancel', 'type' => 'button', 'class' => 'btn btn-default', 'options' => array('label' => 'Cancel', 'label_attributes' => array('sr-only')), 'attributes' => array('value' => 'Cancel', 'class' => 'btn btn-default', 'onClick' => 'top.location=\'' . $url('import', [], true) . '\''))); }