当前位置: 首页>>代码示例>>PHP>>正文


PHP CacheUtil::getLocalDir方法代码示例

本文整理汇总了PHP中CacheUtil::getLocalDir方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheUtil::getLocalDir方法的具体用法?PHP CacheUtil::getLocalDir怎么用?PHP CacheUtil::getLocalDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CacheUtil的用法示例。


在下文中一共展示了CacheUtil::getLocalDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: configure

 /**
  * Fetch and render the configuration template.
  *
  * @return string The rendered template.
  */
 public function configure()
 {
     $modVars = $this->plugin->getVars();
     $options = array('mode' => array('inset', 'outbound'), 'extension' => array('jpg', 'png', 'gif'));
     $this->getView()->assign('vars', $modVars)->assign('thumb_full_dir', CacheUtil::getLocalDir($modVars['thumb_dir']))->assign('options', $options);
     return $this->getView()->fetch('configuration.tpl');
 }
开发者ID:Silwereth,项目名称:core,代码行数:12,代码来源:Configuration.php

示例2: initialize

 /**
  * Initialise.
  *
  * Runs at plugin init time.
  *
  * @return void
  */
 public function initialize(GenericEvent $event)
 {
     // register namespace
     // Because the standard kernel classloader already has Doctrine registered as a namespace
     // we have to add a new loader onto the spl stack.
     $autoloader = new UniversalClassLoader();
     $autoloader->register();
     $autoloader->registerNamespaces(array('DoctrineProxy' => 'ztemp/doctrinemodels'));
     $container = $event->getDispatcher()->getContainer();
     $config = $GLOBALS['ZConfig']['DBInfo']['databases']['default'];
     $dbConfig = array('host' => $config['host'], 'user' => $config['user'], 'password' => $config['password'], 'dbname' => $config['dbname'], 'driver' => 'pdo_' . $config['dbdriver']);
     $r = new \ReflectionClass('Doctrine\\Common\\Cache\\' . $container['dbcache.type'] . 'Cache');
     $dbCache = $r->newInstance();
     $ORMConfig = new \Doctrine\ORM\Configuration();
     $container->set('doctrine.configuration', $ORMConfig);
     $ORMConfig->setMetadataCacheImpl($dbCache);
     // create proxy cache dir
     \CacheUtil::createLocalDir('doctrinemodels');
     // setup annotations base
     include_once \ZLOADER_PATH . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';
     // setup annotation reader
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $cacheReader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
     $container->set('doctrine.annotationreader', $cacheReader);
     // setup annotation driver
     $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cacheReader);
     $container->set('doctrine.annotationdriver', $annotationDriver);
     // setup driver chains
     $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $container->set('doctrine.driverchain', $driverChain);
     // configure Doctrine ORM
     $ORMConfig->setMetadataDriverImpl($annotationDriver);
     $ORMConfig->setQueryCacheImpl($dbCache);
     $ORMConfig->setProxyDir(\CacheUtil::getLocalDir('doctrinemodels'));
     $ORMConfig->setProxyNamespace('DoctrineProxy');
     if (isset($container['log.enabled']) && $container['log.enabled']) {
         $ORMConfig->setSQLLogger(new \Zikula\Core\Doctrine\Logger\ZikulaSqlLogger());
     }
     // setup doctrine eventmanager
     $dispatcher = new \Doctrine\Common\EventManager();
     $container->set('doctrine.eventmanager', $dispatcher);
     // setup MySQL specific listener (storage engine and encoding)
     if ($config['dbdriver'] == 'mysql') {
         $mysqlSessionInit = new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit($config['charset']);
         $dispatcher->addEventSubscriber($mysqlSessionInit);
     }
     // setup the doctrine entitymanager
     $entityManager = \Doctrine\ORM\EntityManager::create($dbConfig, $ORMConfig, $dispatcher);
     $container->set('doctrine.entitymanager', $entityManager);
 }
开发者ID:planetenkiller,项目名称:core,代码行数:57,代码来源:DoctrineListener.php

示例3: __construct

 /**
  * Class constructor.
  *
  * @param string  $feed_url       The URL to the feed (optional).
  * @param integer $cache_duration The duration (in seconds) that the feed contents will be retained in cache.
  */
 public function __construct($feed_url = null, $cache_duration = null, $cache_dir = null)
 {
     parent::__construct();
     if (isset($cache_dir)) {
         $this->set_cache_location($cache_dir);
     } else {
         $this->set_cache_location(CacheUtil::getLocalDir('feeds'));
     }
     if (isset($cache_duration)) {
         $this->set_cache_duration($cache_duration);
     }
     if (isset($feed_url)) {
         $this->set_feed_url($feed_url);
     }
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:21,代码来源:SimplePieFeed.php

示例4: _generateSubclassForCategorisableTemplate

 /**
  * Generates an subclass of the Zikula_Doctrine_Model_EntityCategory class and caches the generated class in a file.
  *
  * @param string $module     Name of the Module to that the model belongs to.
  * @param string $modelClass Classname of the model.
  *
  * @return void
  * @throws Exception Throws when the create of the cache directory fails.
  */
 private static function _generateSubclassForCategorisableTemplate($module, $modelClass)
 {
     $table = Doctrine::getTable($modelClass);
     sscanf($table->getTableName(), Doctrine_Manager::getInstance()->getAttribute(Doctrine::ATTR_TBLNAME_FORMAT), $tableName);
     $dir = 'doctrinemodels/GeneratedDoctrineModel/' . str_replace('_', DIRECTORY_SEPARATOR, $modelClass);
     if (CacheUtil::createLocalDir($dir, ServiceUtil::getManager()->getParameter('system.chmod_dir'))) {
         $subclassName = 'GeneratedDoctrineModel_' . $modelClass . '_EntityCategory';
         $fileContents = '<?php class ' . $subclassName . ' extends Zikula_Doctrine_Model_EntityCategory { }';
         $fileName = 'EntityCategory.php';
         // save new model
         file_put_contents(CacheUtil::getLocalDir() . '/' . $dir . '/' . $fileName, $fileContents);
         // save required data for later use
         $modelsInfo = ModUtil::getVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', array());
         $modelsInfo[$subclassName] = array('module' => $module, 'table' => $tableName);
         ModUtil::setVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', $modelsInfo);
     } else {
         throw new Exception('Creation of the cache directory ' . $dir . ' failed');
     }
 }
开发者ID:Silwereth,项目名称:core,代码行数:28,代码来源:Categorisable.php

示例5: clear_theme_config

 /**
  * Clears the Theme configuration located on the temporary directory.
  *
  * @return boolean True on success, false otherwise.
  */
 public function clear_theme_config()
 {
     $configdir = CacheUtil::getLocalDir('Theme_Config');
     return $this->clear_folder($configdir, null, null, null);
 }
开发者ID:rmaiwald,项目名称:core,代码行数:10,代码来源:Theme.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param Zikula_ServiceManager $serviceManager ServiceManager.
  * @param string                $moduleName     Module name ("zikula" for system plugins).
  * @param integer|null          $caching        Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
  */
 public function __construct(Zikula_ServiceManager $serviceManager, $moduleName = '', $caching = null)
 {
     $this->serviceManager = $serviceManager;
     $this->eventManager = $this->serviceManager->get('event_dispatcher');
     $this->request = \ServiceUtil::get('request');
     // set the error reporting level
     $this->error_reporting = isset($GLOBALS['ZConfig']['Debug']['error_reporting']) ? $GLOBALS['ZConfig']['Debug']['error_reporting'] : E_ALL;
     $this->error_reporting &= ~E_USER_DEPRECATED;
     $this->allow_php_tag = true;
     // get variables from input
     $module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
     $type = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     $func = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
     // set vars based on the module structures
     $this->homepage = PageUtil::isHomepage();
     $this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
     $this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));
     // Initialize the module property with the name of
     // the topmost module. For Hooks, Blocks, API Functions and others
     // you need to set this property to the name of the respective module!
     $this->toplevelmodule = ModUtil::getName();
     if (!$moduleName) {
         $moduleName = $this->toplevelmodule;
     }
     $this->modinfo = ModUtil::getInfoFromName($moduleName);
     $this->module = array($moduleName => $this->modinfo);
     // initialise environment vars
     $this->language = ZLanguage::getLanguageCode();
     $this->baseurl = System::getBaseUrl();
     $this->baseuri = System::getBaseUri();
     // system info
     $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
     $this->theme = $theme = $this->themeinfo['directory'];
     $themeBundle = ThemeUtil::getTheme($this->themeinfo['name']);
     //---- Plugins handling -----------------------------------------------
     // add plugin paths
     switch ($this->modinfo['type']) {
         case ModUtil::TYPE_MODULE:
             $mpluginPathNew = "modules/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "modules/" . $this->modinfo['directory'] . "/templates/plugins";
             break;
         case ModUtil::TYPE_SYSTEM:
             $mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
             break;
         default:
             $mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
     }
     // add standard plugin search path
     $this->plugins_dir = array();
     $this->addPluginDir('config/plugins');
     // Official override
     $this->addPluginDir('lib/legacy/viewplugins');
     // Core plugins
     $this->addPluginDir(isset($themeBundle) ? $themeBundle->getRelativePath() . '/plugins' : "themes/{$theme}/plugins");
     // Theme plugins
     $this->addPluginDir('plugins');
     // Smarty core plugins
     $this->addPluginDir($mpluginPathNew);
     // Plugins for current module
     $this->addPluginDir($mpluginPath);
     // Plugins for current module
     // check if the 'type' parameter in the URL is admin or adminplugin
     $legacyControllerType = FormUtil::getPassedValue('lct', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     if ($type === 'admin' || $type === 'adminplugin' || $legacyControllerType === 'admin') {
         // include plugins of the Admin module to the plugins_dir array
         if (!$this instanceof Zikula_View_Theme) {
             $this->addPluginDir('system/AdminModule/Resources/views/plugins');
         } else {
             $this->load_filter('output', 'admintitle');
         }
     }
     // theme plugins module overrides
     $themePluginsPath = isset($themeBundle) ? $themeBundle->getRelativePath() . '/modules/$moduleName/plugins' : "themes/{$theme}/templates/modules/{$moduleName}/plugins";
     $this->addPluginDir($themePluginsPath);
     //---- Cache handling -------------------------------------------------
     if ($caching && in_array((int) $caching, array(0, 1, 2))) {
         $this->caching = (int) $caching;
     } else {
         $this->caching = (int) ModUtil::getVar('ZikulaThemeModule', 'render_cache');
     }
     $this->compile_id = '';
     $this->cache_id = '';
     // template compilation
     $this->compile_dir = CacheUtil::getLocalDir('view_compiled');
     $this->compile_check = ModUtil::getVar('ZikulaThemeModule', 'render_compile_check');
     $this->force_compile = ModUtil::getVar('ZikulaThemeModule', 'render_force_compile');
     // template caching
     $this->cache_dir = CacheUtil::getLocalDir('view_cache');
     $this->cache_lifetime = ModUtil::getVar('ZikulaThemeModule', 'render_lifetime');
     $this->expose_template = ModUtil::getVar('ZikulaThemeModule', 'render_expose_template') == true ? true : false;
     // register resource type 'z' this defines the way templates are searched
//.........这里部分代码省略.........
开发者ID:Silwereth,项目名称:core,代码行数:101,代码来源:View.php

示例7: checkRunningConfig

    /**
     * Running config checker
     */
    private function checkRunningConfig($themeinfo)
    {
        $ostemp = CacheUtil::getLocalDir();
        $zpath  = $ostemp.'/Theme_Config/'.DataUtil::formatForOS($themeinfo['directory']);
        $tpath  = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/templates/config';

        // check if we can edit the theme and, if not, create the running config
        if (!is_writable($tpath.'/pageconfigurations.ini')) {
            if (!file_exists($zpath) || is_writable($zpath)) {
                ModUtil::apiFunc('Theme', 'admin', 'createrunningconfig', array('themename' => $themeinfo['name']));

                LogUtil::registerStatus($this->__f('Notice: The changes made via Admin Panel will be saved on \'%1$s\' because it seems that the .ini files on \'%2$s\' are not writable.', array($zpath, $tpath)));

            } else {
                LogUtil::registerError($this->__f('Error! Cannot write any configuration changes. Make sure that the .ini files on \'%1$s\' or \'%2$s\', and the folder itself, are writable.', array($tpath, $zpath)));
            }
        } else {
            LogUtil::registerStatus($this->__f('Notice: Seems that your %1$s\'s .ini files are writable. Be sure that there are no .ini files on \'%2$s\' because if so, the Theme Engine will consider them and not your %1$s\'s ones.', array($themeinfo['name'], $zpath)));
        }

        LogUtil::registerStatus($this->__f("If the system cannot write on any .ini file, the changes will be saved on '%s' and the Theme Engine will use it.", $zpath));
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:25,代码来源:Admin.php

示例8: pdfIsCached

 /**
  * Check to see if file is cached and current
  * return false if !exists or !current
  * return full filepath if exists and current
  *
  * @param string $title
  * @return mixed boolean/string
  */
 private function pdfIsCached($title)
 {
     $dir = CacheUtil::getLocalDir('NewsPDF');
     if (!is_dir($dir)) {
         CacheUtil::createLocalDir('NewsPDF', 0755, true);
     }
     $title = $title . '.pdf';
     // modify title like the tcpdf::Output() method does
     $title = preg_replace('/[\s]+/', '_', $title);
     $title = preg_replace('/[^a-zA-Z0-9_\.-]/', '', $title);
     $fullpath = $dir . '/' . $title;
     if (file_exists($fullpath)) {
         // check if expired
         if ((time() - filemtime($fullpath)) > ModUtil::getVar('Theme', 'render_lifetime')) {
             return false;
         }
     } else {
         return false;
     }
     return $fullpath;
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:29,代码来源:User.php

示例9: deleteinifile

    /**
     * delete ini file
     */
    public function deleteinifile($args)
    {
        if (!isset($args['themename']) || empty($args['themename'])) {
            return LogUtil::registerArgsError();
        } else {
            $themename = $args['themename'];
        }

        // Security check
        if (!SecurityUtil::checkPermission('Theme::', "$themename", ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        if (!isset($args['file']) || empty($args['file'])) {
            return LogUtil::registerArgsError();
        }

        $ostemp  = CacheUtil::getLocalDir();
        $ostheme = DataUtil::formatForOS($themename);
        $osfile  = $ostemp.'/Theme_Config/'.$ostheme.'/'.DataUtil::formatForOS($args['file']);

        if (file_exists($osfile) && is_writable($osfile)) {
            unlink($osfile);
        }
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:28,代码来源:Admin.php

示例10: getfeed

    /**
     * Get Feeds via SimplePie
     *
     * @param integer fid feed id (not required if feed url is present)
     * @param string  furl feed url or urls for Multifeed request (not requred if feed id is present)
     * @param integer limit set how many items are returned per feed with Multifeeds (default is all)
     * @param integer cron  set to 1 to update all caches right now (default is 0, update cache only if needed)
     * @return mixed item array containing total item count, error information, and object with all the requested feeds
     */
    public function getfeed($args)
    {
        if (!PluginUtil::isAvailable('systemplugin.simplepie')) {
            throw new Exception(__('<strong>Fatal error: The required SimplePie system plugin is not available.</strong>'));
        }

        // Argument check
        if ((!isset($args['fid']) || !is_numeric($args['fid']))
                && (!isset($args['furl']) || (!is_string($args['furl']) && (!is_array($args['furl']))))) {
            return LogUtil::registerArgsError();
        }

        // Optional arguments.
        if (!isset($args['limit']) || !is_numeric($args['limit'])) {
            $args['limit'] = 0;  // 0 = don't set a limit
        }
        if (!isset($args['cron']) || !is_numeric($args['cron'])) {
            $args['cron'] = 0;  // not a cron job update
        } else {
            $args['cron'] = 1;  // it is a cron job update
        }

        // get all module vars for later use
        $modvars = $this->getVars();

        // check if the feed id is set, grab the feed from the db
        if (isset($args['fid'])) {
            $feed = ModUtil::apiFunc('Feeds', 'user', 'get', array('fid' => $args['fid']));
            $url = $feed['url'];
        } elseif(isset($args['furl'])) {
            $url = $args['furl'];
        }

        // Now setup SimplePie for the feed
        $theFeed = new SimplePieFeed();
        $theFeed->set_feed_url($url);
        $theFeed->set_cache_location(CacheUtil::getLocalDir($modvars['cachedirectory']));
        $theFeed->enable_order_by_date(true);

        // Get the charset used for the output, and tell SimplePie about it so it will try to use the same for its output
        $charset = ZLanguage::getDBCharset();
        if ($charset != '') {
            $theFeed->set_output_encoding($charset);
        }

        // Set the feed limits (note: this is a per feed limit that applies if multiple feeds are used)
        if ($args['limit'] > 0) {
            $theFeed->set_item_limit($args['limit']);
        }

        // Set Cache Duration
        if ($args['cron'] == 1) {
            $theFeed->set_cache_duration(0);          // force cache to update immediately (a cron job needs to do that)

        } elseif ($modvars['usingcronjob'] == 1) {   // Using a cron job to update the cache (but not this time), so per SimplePie docs...
            $theFeed->set_cache_duration(999999999);  // set to 999999999 to not update the cache with this request
            $theFeed->set_timeout(-1);                // set timeout to -1 to prevent SimplePie from retrying previous failed feeds

        } else {
            $theFeed->set_cache_duration($modvars['cacheinterval']);  // Use the specified cache interval.
        }

        // tell SimplePie to go and do its thing
        $theFeed->init();

        $returnFeed['count'] = $theFeed->get_item_quantity(); // total items returned
        $returnFeed['error'] = $theFeed->error();             // Return any errors
        $returnFeed['feed']  = $theFeed;                      // The feed information

        // Per SimplePie documentation, there is a bug in versions of PHP older than 5.3 where PHP doesn't release memory properly in certain cases.
        // This is the workaround
        $theFeed->__destruct();
        unset($theFeed);

        return $returnFeed;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:85,代码来源:User.php

示例11: setupThumbDir

 /**
  * Setup or restore storage directory.
  *
  * @param string $dir Storage directory (inside Zikula "ztemp" dir)
  *
  * @return bool
  */
 public function setupThumbDir($dir = null)
 {
     if (is_null($dir)) {
         $dir = $this->getVar('thumb_dir');
     }
     if (!($result = file_exists(CacheUtil::getLocalDir($dir)))) {
         $result = CacheUtil::createLocalDir($dir);
     }
     if ($result) {
         $dir = CacheUtil::getLocalDir($dir);
         $htaccess = "{$dir}/.htaccess";
         if (!file_exists($htaccess)) {
             $template = "{$this->getBaseDir()}/templates/default.htaccess";
             $result = copy($template, $htaccess);
         }
     }
     return $result;
 }
开发者ID:rmaiwald,项目名称:core,代码行数:25,代码来源:Plugin.php

示例12: downloadAction

 /**
  * @Route("/download/{slug}.zip", requirements={"slug"=".+"})
  * @ParamConverter("entity", class="Cmfcmf\Module\MediaModule\Entity\Collection\CollectionEntity", options={"slug" = "slug"})
  *
  * @param Request          $request
  * @param CollectionEntity $entity
  *
  * @return array
  */
 public function downloadAction(CollectionEntity $entity)
 {
     if (!$this->get('cmfcmf_media_module.security_manager')->hasPermission($entity, 'download')) {
         throw new AccessDeniedException();
     }
     \CacheUtil::createLocalDir('CmfcmfMediaModule');
     $dir = \CacheUtil::getLocalDir('CmfcmfMediaModule');
     $path = $dir . '/' . uniqid(time(), true) . '.zip';
     $zip = new \ZipArchive();
     if ($zip->open($path, \ZipArchive::CREATE) !== true) {
         throw new ServiceUnavailableHttpException('Could not create zip archive!');
     }
     $mediaTypeCollection = $this->get('cmfcmf_media_module.media_type_collection');
     $hasContent = false;
     $usedFileNames = [];
     foreach ($entity->getMedia() as $media) {
         if ($media instanceof AbstractFileEntity && $media->isDownloadAllowed()) {
             /** @var UploadableMediaTypeInterface $mediaType */
             $mediaType = $mediaTypeCollection->getMediaTypeFromEntity($media);
             $filename = $media->getBeautifiedFileName();
             $originalFileExtension = pathinfo($filename, PATHINFO_EXTENSION);
             $originalFilename = pathinfo($filename, PATHINFO_BASENAME);
             for ($i = 1; in_array($filename, $usedFileNames, true); ++$i) {
                 $filename = "{$originalFilename} ({$i})" . (empty($originalFileExtension) ?: ".{$originalFileExtension}");
             }
             $zip->addFile($mediaType->getOriginalWithWatermark($media, 'path', false), $filename);
             $hasContent = true;
         }
     }
     if (!$hasContent) {
         $zip->addFromString('Empty Collection.txt', $this->__('Sorry, the collection appears to be empty or does not have any downloadable files.'));
     }
     $zip->close();
     $response = new BinaryFileResponse($path);
     $response->deleteFileAfterSend(true);
     return $response;
 }
开发者ID:shefik,项目名称:MediaModule,代码行数:46,代码来源:CollectionController.php

示例13: initialize

    /**
     * Initialise.
     *
     * Runs at plugin init time.
     *
     * @return void
     */
    public function initialize()
    {
        // register namespace
        // Because the standard kernel classloader already has Doctrine registered as a namespace
        // we have to add a new loader onto the spl stack.
        $autoloader = new Zikula_KernelClassLoader();
        $autoloader->spl_autoload_register();
        include 'lib/DoctrineHelper.php';
        $autoloader->register('Doctrine', dirname(__FILE__) . '/lib/vendor', '\\');
        $autoloader->register('DoctrineProxy', 'ztemp/doctrinemodels', '\\');

        $serviceManager = $this->eventManager->getServiceManager();
        $config = $GLOBALS['ZConfig']['DBInfo']['databases']['default'];
        $dbConfig = array('host' => $config['host'],
                          'user' => $config['user'],
                          'password' => $config['password'],
                          'dbname' => $config['dbname'],
                          'driver' => 'pdo_' . $config['dbdriver'],
                          );
        $r = new \ReflectionClass('Doctrine\Common\Cache\\' . $serviceManager['dbcache.type'] . 'Cache');
        $dbCache = $r->newInstance();
        $ORMConfig = new \Doctrine\ORM\Configuration;
        $serviceManager->attachService('doctrine.configuration', $ORMConfig);
        $ORMConfig->setMetadataCacheImpl($dbCache);

        // create proxy cache dir
        CacheUtil::createLocalDir('doctrinemodels');

        // setup annotations base
        include_once 'lib/vendor/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';

        // setup annotation reader
        $reader = new \Doctrine\Common\Annotations\AnnotationReader();
        $cacheReader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
        $serviceManager->attachService('doctrine.annotationreader', $cacheReader);

        // setup annotation driver
        $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cacheReader);
        $serviceManager->attachService('doctrine.annotationdriver', $annotationDriver);

        // setup driver chains
        $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain();
        $serviceManager->attachService('doctrine.driverchain', $driverChain);

        // configure Doctrine ORM
        $ORMConfig->setMetadataDriverImpl($annotationDriver);
        $ORMConfig->setQueryCacheImpl($dbCache);
        $ORMConfig->setProxyDir(CacheUtil::getLocalDir('doctrinemodels'));
        $ORMConfig->setProxyNamespace('DoctrineProxy');
        //$ORMConfig->setAutoGenerateProxyClasses(System::isDevelopmentMode());

        if (isset($serviceManager['log.enabled']) && $serviceManager['log.enabled']) {
            $ORMConfig->setSQLLogger(new SystemPlugin_Doctrine_ZikulaSqlLogger());
        }

        // setup doctrine eventmanager
        $eventManager = new \Doctrine\Common\EventManager;
        $serviceManager->attachService('doctrine.eventmanager', $eventManager);

         // setup MySQL specific listener (storage engine and encoding)
        if ($config['dbdriver'] == 'mysql') {
            $mysqlSessionInit = new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit($config['charset']);
            $eventManager->addEventSubscriber($mysqlSessionInit);

            $mysqlStorageEvent = new SystemPlugin_Doctrine_MySqlGenerateSchemaListener($eventManager);
        }

        // setup the doctrine entitymanager
        $entityManager = \Doctrine\ORM\EntityManager::create($dbConfig, $ORMConfig, $eventManager);
        $serviceManager->attachService('doctrine.entitymanager', $entityManager);
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:78,代码来源:Plugin.php

示例14: updateconfig


//.........这里部分代码省略.........
        $sessionregeneratefreq = (int)FormUtil::getPassedValue('sessionregeneratefreq', 10, 'POST');
        if ($sessionregeneratefreq < 1 || $sessionregeneratefreq > 100) {
            $sessionregeneratefreq = 10;
        }
        System::setVar('sessionregeneratefreq', $sessionregeneratefreq);

        $sessionipcheck = (int)FormUtil::getPassedValue('sessionipcheck', 0, 'POST');
        System::setVar('sessionipcheck', $sessionipcheck);

        $sessionname = FormUtil::getPassedValue('sessionname', 'ZSID', 'POST');
        if (strlen($sessionname) < 3) {
            $sessionname = 'ZSID';
        }

        $sessioncsrftokenonetime = (int)FormUtil::getPassedValue('sessioncsrftokenonetime', 0, 'POST');
        System::setVar('sessioncsrftokenonetime', $sessioncsrftokenonetime);

        // cause logout if we changed session name
        if ($sessionname != System::getVar('sessionname')) {
            $cause_logout = true;
        }

        System::setVar('sessionname', $sessionname);
        System::setVar('sessionstoretofile', $sessionstoretofile);

        $outputfilter = FormUtil::getPassedValue('outputfilter', 0, 'POST');
        System::setVar('outputfilter', $outputfilter);

        $useids = (bool)FormUtil::getPassedValue('useids', 0, 'POST');
        System::setVar('useids', $useids);

        // create tmp directory for PHPIDS
        if ($useids == 1) {
            $idsTmpDir = CacheUtil::getLocalDir() . '/idsTmp';
            if (!file_exists($idsTmpDir)) {
                CacheUtil::clearLocalDir('idsTmp');
            }
        }

        $idssoftblock = (bool)FormUtil::getPassedValue('idssoftblock', 1, 'POST');
        System::setVar('idssoftblock', $idssoftblock);

        $idsmail = (bool)FormUtil::getPassedValue('idsmail', 1, 'POST');
        System::setVar('idsmail', $idsmail);

        $idsfilter = FormUtil::getPassedValue('idsfilter', 'xml', 'POST');
        System::setVar('idsfilter', $idsfilter);

        $idsrulepath = FormUtil::getPassedValue('idsrulepath', 'config/zikula_default.xml', 'POST');
        $idsrulepath = DataUtil::formatForOS($idsrulepath);
        if (is_readable($idsrulepath)) {
            System::setVar('idsrulepath', $idsrulepath);
        } else {
            LogUtil::registerError($this->__f('Error! PHPIDS rule file %s does not exist or is not readable.', $idsrulepath));
            $validates = false;
        }

        $idsimpactthresholdone = (int)FormUtil::getPassedValue('idsimpactthresholdone', 1, 'POST');
        System::setVar('idsimpactthresholdone', $idsimpactthresholdone);

        $idsimpactthresholdtwo = (int)FormUtil::getPassedValue('idsimpactthresholdtwo', 10, 'POST');
        System::setVar('idsimpactthresholdtwo', $idsimpactthresholdtwo);

        $idsimpactthresholdthree = (int)FormUtil::getPassedValue('idsimpactthresholdthree', 25, 'POST');
        System::setVar('idsimpactthresholdthree', $idsimpactthresholdthree);
开发者ID:projectesIF,项目名称:Sirius,代码行数:66,代码来源:Admin.php

示例15: deleteGeneratedCategoryModelsOnModuleRemove

 /**
  * On an module remove hook call this listener deletes all cached (generated) doctrine models for the module.
  *
  * Listens for the 'installer.module.uninstalled' event.
  *
  * @param Zikula_Event $event Event.
  *
  * @return void
  */
 public function deleteGeneratedCategoryModelsOnModuleRemove(Zikula_Event $event)
 {
     $moduleName = $event['name'];
     // remove generated category models for this record
     $dir = 'doctrinemodels/GeneratedDoctrineModel/' . $moduleName;
     if (file_exists(CacheUtil::getLocalDir($dir))) {
         CacheUtil::removeLocalDir($dir, true);
     }
     // remove saved data about the record
     $modelsInfo = ModUtil::getVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', array());
     foreach ($modelsInfo as $class => $info) {
         if ($info['module'] == $moduleName) {
             unset($modelsInfo[$class]);
         }
     }
     ModUtil::setVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', $modelsInfo);
 }
开发者ID:Silwereth,项目名称:core,代码行数:26,代码来源:SystemListeners.php


注:本文中的CacheUtil::getLocalDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。