本文整理汇总了PHP中ServiceUtil::getManager方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceUtil::getManager方法的具体用法?PHP ServiceUtil::getManager怎么用?PHP ServiceUtil::getManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceUtil
的用法示例。
在下文中一共展示了ServiceUtil::getManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReviewRepository
/**
*
This method is for getting a repository for reviews
*
*/
public static function getReviewRepository()
{
$serviceManager = ServiceUtil::getManager();
$entityManager = $serviceManager->getService('doctrine.entitymanager');
$repository = $entityManager->getRepository('Reviews_Entity_Review');
return $repository;
}
示例2: loadData
/**
* Loads the data.
*
* @param array $data Data array with parameters.
*/
public function loadData(&$data)
{
$serviceManager = ServiceUtil::getManager();
$controllerHelper = new MUVideo_Util_Controller($serviceManager);
$utilArgs = array('name' => 'detail');
if (!isset($data['objectType']) || !in_array($data['objectType'], $controllerHelper->getObjectTypes('contentType', $utilArgs))) {
$data['objectType'] = $controllerHelper->getDefaultObjectType('contentType', $utilArgs);
}
$this->objectType = $data['objectType'];
if (!isset($data['id'])) {
$data['id'] = null;
}
if (!isset($data['moviewidth'])) {
$data['moviewidth'] = 400;
}
$this->moviewidth = $data['moviewidth'];
if (!isset($data['movieheight'])) {
$data['movieheight'] = 300;
}
$this->movieheight = $data['movieheight'];
if (!isset($data['displayMode'])) {
$data['displayMode'] = 'embed';
}
$this->id = $data['id'];
$this->displayMode = $data['displayMode'];
}
示例3: __construct
/**
* Constructor.
*
* @param integer $objectId Identifier of treated object.
* @param integer $areaId Name of hook area.
* @param string $module Name of the owning module.
* @param string $urlString **deprecated**
* @param Zikula_ModUrl $urlObject Object carrying url arguments.
*/
function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null)
{
// call base constructor to store arguments in member vars
parent::__construct($objectId, $areaId, $module, $urlString, $urlObject);
// derive object type from url object
$urlArgs = $urlObject->getArgs();
$objectType = isset($urlArgs['ot']) ? $urlArgs['ot'] : 'review';
$component = $module . ':' . ucwords($objectType) . ':';
$perm = SecurityUtil::checkPermission($component, $objectId . '::', ACCESS_READ);
if (!$perm) {
return;
}
$entityClass = $module . '_Entity_' . ucwords($objectType);
$serviceManager = ServiceUtil::getManager();
$entityManager = $serviceManager->getService('doctrine.entitymanager');
$repository = $entityManager->getRepository($entityClass);
$useJoins = false;
/** TODO support composite identifiers properly at this point */
$entity = $repository->selectById($objectId, $useJoins);
if ($entity === false || !is_array($entity) && !is_object($entity)) {
return;
}
$this->setObjectTitle($entity->getTitleFromDisplayPattern());
$dateFieldName = $repository->getStartDateFieldName();
if ($dateFieldName != '') {
$this->setObjectDate($entity[$dateFieldName]);
} else {
$this->setObjectDate('');
}
if (method_exists($entity, 'getCreatedUserId')) {
$this->setObjectAuthor(UserUtil::getVar('uname', $entity['createdUserId']));
} else {
$this->setObjectAuthor('');
}
}
示例4: removeLocalDir
/**
* Remove a directory from zikula's local cache directory.
*
* @param string $dir The name of the directory to remove.
* @param bool $absolute Whether to process the passed dir as an absolute path or not.
*
* @return boolean true if successful, false otherwise.
*/
public static function removeLocalDir($dir, $absolute = false)
{
$sm = ServiceUtil::getManager();
$base = $sm['kernel.cache_dir'] . '/ztemp';
$path = $base . '/' . $dir;
return FileUtil::deldir($path, $absolute);
}
示例5: getTimeDiff
/**
* Returns the page render time.
*
* @return number
*/
public function getTimeDiff()
{
$start = \ServiceUtil::getManager()->getParameter('debug.toolbar.panel.rendertime.start');
$end = microtime(true);
$diff = $end - $start;
return $diff;
}
示例6: sync
/**
* Sync the filesystem scan and the Bundles table
* This is a 'dumb' scan - there is no state management here
* state management occurs in the module and theme management
* and is checked in Bundle/Bootstrap
*
* @param $array array of extensions
* obtained from filesystem scan
* key is bundle name and value an instance of \Zikula\Bundle\CoreBundle\Bundle\MetaData
*/
private function sync($array)
{
// add what is in array but missing from db
/** @var $metadata MetaData */
foreach ($array as $name => $metadata) {
$qb = $this->conn->createQueryBuilder();
$qb->select('b.id', 'b.bundlename', 'b.bundleclass', 'b.autoload', 'b.bundletype', 'b.bundlestate')->from('bundles', 'b')->where('b.bundlename = :name')->setParameter('name', $name);
$result = $qb->execute();
$row = $result->fetch();
if (!$row) {
// bundle doesn't exist
$this->insert($metadata);
} elseif ($metadata->getClass() != $row['bundleclass'] || serialize($metadata->getAutoload()) != $row['autoload']) {
// bundle json has been updated
$updatedMeta = array("bundleclass" => $metadata->getClass(), "autoload" => serialize($metadata->getAutoload()));
$this->conn->update('bundles', $updatedMeta, array('id' => $row['id']));
}
}
// remove what is in db but missing from array
$qb = $this->conn->createQueryBuilder();
$qb->select('b.id', 'b.bundlename', 'b.bundleclass', 'b.autoload', 'b.bundletype', 'b.bundlestate')->from('bundles', 'b');
$res = $qb->execute();
foreach ($res->fetchAll() as $row) {
if (!in_array($row['bundlename'], array_keys($array))) {
$this->removeById($row['id']);
}
}
// clear the cache
/** @var $cacheClearer \Zikula\Bundle\CoreBundle\CacheClearer */
$cacheClearer = \ServiceUtil::getManager()->get('zikula.cache_clearer');
$cacheClearer->clear('symfony.config');
}
示例7: getPluginInstance
/**
* Setup the current instance of the Zikula_View class and return it back to the module.
*
* @param string $moduleName Module name.
* @param string $pluginName Plugin name.
* @param integer|null $caching Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
* @param string $cache_id Cache Id.
*
* @return Zikula_View_Plugin instance.
*/
public static function getPluginInstance($moduleName, $pluginName, $caching = null, $cache_id = null)
{
$serviceManager = ServiceUtil::getManager();
$serviceId = strtolower(sprintf('zikula.renderplugin.%s.%s', $moduleName, $pluginName));
if (!$serviceManager->has($serviceId)) {
$view = new self($serviceManager, $moduleName, $pluginName, $caching);
$serviceManager->set($serviceId, $view);
} else {
return $serviceManager->get($serviceId);
}
if (!is_null($caching)) {
$view->caching = $caching;
}
if (!is_null($cache_id)) {
$view->cache_id = $cache_id;
}
if ($moduleName === null) {
$moduleName = $view->toplevelmodule;
}
if (!array_key_exists($moduleName, $view->module)) {
$view->module[$moduleName] = ModUtil::getInfoFromName($moduleName);
//$instance->modinfo = ModUtil::getInfoFromName($module);
$view->_addPluginsDir($moduleName);
}
// for {gt} template plugin to detect gettext domain
if ($view->module[$moduleName]['type'] == ModUtil::TYPE_MODULE || $view->module[$moduleName]['type'] == ModUtil::TYPE_SYSTEM) {
$view->domain = ZLanguage::getModulePluginDomain($view->module[$moduleName]['name'], $view->getPluginName());
} elseif ($view->module[$moduleName]['type'] == ModUtil::TYPE_CORE) {
$view->domain = ZLanguage::getSystemPluginDomain($view->getPluginName());
}
return $view;
}
示例8: prepareJCSS
/**
* The main procedure for managing stylesheets and javascript files.
*
* Gets demanded files from PageUtil variables, check them and resolve dependencies.
* Returns an array with two arrays, containing list of js and css files
* ready to embedded in the HTML HEAD.
*
* @param bool $combine Should files be combined.
* @param string $cache_dir Path to cache directory.
*
* @return array Array with two array containing the files to be embedded into HTML HEAD
*/
public static function prepareJCSS($combine = false, $cache_dir = null)
{
$combine = $combine && is_writable($cache_dir);
$jcss = array();
// get page vars
$javascripts = PageUtil::getVar('javascript');
$stylesheets = PageUtil::getVar('stylesheet');
$javascripts = self::prepareJavascripts($javascripts, $combine);
// update stylesheets as there might be some additions for js
$stylesheets = array_merge((array) $stylesheets, (array) PageUtil::getVar('stylesheet'));
$stylesheets = self::prepareStylesheets($stylesheets, $combine);
if ($combine) {
$javascripts = (array) self::save($javascripts, 'js', $cache_dir);
$stylesheets = (array) self::save($stylesheets, 'css', $cache_dir);
}
/* @var \Symfony\Component\HttpFoundation\Request $request */
$request = ServiceUtil::getManager()->get('request');
$basePath = $request->getBasePath();
foreach ($stylesheets as $key => $value) {
$stylesheets[$key] = $basePath . '/' . $value;
}
foreach ($javascripts as $key => $value) {
$javascripts[$key] = $basePath . '/' . $value;
}
$jcss = array('stylesheets' => $stylesheets, 'javascripts' => $javascripts);
// some core js libs require js gettext - ensure that it will be loaded
$jsgettext = self::getJSGettext();
if (!empty($jsgettext)) {
array_unshift($jcss['javascripts'], $jsgettext);
}
return $jcss;
}
示例9: getMovieRepository
/**
*
This method is for getting a repository for movies
*
*/
public static function getMovieRepository()
{
$serviceManager = ServiceUtil::getManager();
$entityManager = $serviceManager->getService('doctrine.entitymanager');
$repository = $entityManager->getRepository('MUVideo_Entity_Movie');
return $repository;
}
示例10: Reviews_operation_update
/**
* Update operation.
* @param object $entity The treated object.
* @param array $params Additional arguments.
*
* @return bool False on failure or true if everything worked well.
*/
function Reviews_operation_update(&$entity, $params)
{
$dom = ZLanguage::getModuleDomain('Reviews');
// initialise the result flag
$result = false;
$objectType = $entity['_objectType'];
$currentState = $entity['workflowState'];
// get attributes read from the workflow
if (isset($params['nextstate']) && !empty($params['nextstate'])) {
// assign value to the data object
$entity['workflowState'] = $params['nextstate'];
if ($params['nextstate'] == 'archived') {
// bypass validator (for example an end date could have lost it's "value in future")
$entity['_bypassValidation'] = true;
}
}
// get entity manager
$serviceManager = ServiceUtil::getManager();
$entityManager = $serviceManager->getService('doctrine.entitymanager');
// save entity data
try {
//$this->entityManager->transactional(function($entityManager) {
$entityManager->persist($entity);
$entityManager->flush();
//});
$result = true;
} catch (\Exception $e) {
LogUtil::registerError($e->getMessage());
}
// return result of this operation
return $result;
}
示例11: bootstrap
protected function bootstrap($disableSessions = true, $loadZikulaCore = true, $fakeRequest = true)
{
define('_ZINSTALLVER', \Zikula_Core::VERSION_NUM);
$kernel = $this->getContainer()->get('kernel');
$loader = (require $kernel->getRootDir() . '/autoload.php');
\ZLoader::register($loader);
if ($loadZikulaCore && !$this->getContainer()->has('zikula')) {
$core = new Zikula_Core();
$core->setKernel($kernel);
$core->boot();
foreach ($GLOBALS['ZConfig'] as $config) {
$core->getContainer()->loadArguments($config);
}
$GLOBALS['ZConfig']['System']['temp'] = $core->getContainer()->getParameter('temp_dir');
$GLOBALS['ZConfig']['System']['datadir'] = $core->getContainer()->getParameter('datadir');
$GLOBALS['ZConfig']['System']['system.chmod_dir'] = $core->getContainer()->getParameter('system.chmod_dir');
\ServiceUtil::getManager($core);
\EventUtil::getManager($core);
}
if ($disableSessions) {
// Disable sessions.
$this->getContainer()->set('session.storage', new MockArraySessionStorage());
$this->getContainer()->set('session.handler', new NullSessionHandler());
}
if ($fakeRequest) {
// Fake request
$request = Request::create('http://localhost/install');
$this->getContainer()->set('request', $request);
}
}
示例12: smarty_modifier_zikularoutesmoduleGetListEntry
/**
* The zikularoutesmoduleGetListEntry modifier displays the name
* or names for a given list item.
*
* @param string $value The dropdown value to process.
* @param string $objectType The treated object type.
* @param string $fieldName The list field's name.
* @param string $delimiter String used as separator for multiple selections.
*
* @return string List item name.
*/
function smarty_modifier_zikularoutesmoduleGetListEntry($value, $objectType = '', $fieldName = '', $delimiter = ', ')
{
if (empty($value) && $value != '0' || empty($objectType) || empty($fieldName)) {
return $value;
}
$serviceManager = ServiceUtil::getManager();
$helper = $serviceManager->get('zikularoutesmodule.listentries_helper');
return $helper->resolve($value, $objectType, $fieldName, $delimiter);
}
示例13: createLocalDir
/**
* Create a directory below zikula's local cache directory.
*
* @param string $dir The name of the directory to create.
* @param mixed $mode The (UNIX) mode we wish to create the files with.
* @param bool $absolute Whether to process the passed dir as an absolute path or not.
*
* @return boolean true if successful, false otherwise.
*/
public static function createLocalDir($dir, $mode = 0777, $absolute = true)
{
$path = DataUtil::formatForOS(System::getVar('temp'), true) . '/' . $dir;
$mode = isset($mode) ? $mode : ServiceUtil::getManager()->getParameter('system.chmod_dir');
if (!FileUtil::mkdirs($path, $mode, $absolute)) {
return false;
}
return true;
}
示例14: smarty_modifier_muvideoGetListEntry
/**
* The muvideoGetListEntry modifier displays the name
* or names for a given list item.
*
* @param string $value The dropdown value to process.
* @param string $objectType The treated object type.
* @param string $fieldName The list field's name.
* @param string $delimiter String used as separator for multiple selections.
*
* @return string List item name.
*/
function smarty_modifier_muvideoGetListEntry($value, $objectType = '', $fieldName = '', $delimiter = ', ')
{
if (empty($value) || empty($objectType) || empty($fieldName)) {
return $value;
}
$serviceManager = ServiceUtil::getManager();
$helper = new MUVideo_Util_ListEntries($serviceManager);
return $helper->resolve($value, $objectType, $fieldName, $delimiter);
}
示例15: delVar
/**
* Delete a session variable.
*
* @param string $name Name of the session variable to delete.
* @param mixed $default The default value to return if the requested session variable is not set.
* @param string $path Path to traverse to reach the element we wish to return (optional) (default='/').
*
* @return mixed The value of the session variable being deleted, or the value provided in $default if the variable is not set.
*/
public static function delVar($name, $default = false, $path = '/')
{
$session = ServiceUtil::getManager()->get('session');
if ($path != '/' || $path != '') {
$name = "{$path}/{$name}";
}
$value = $session->get($name, $default);
$session->remove($name, $path);
return $value;
}