本文整理汇总了PHP中ProjectConfiguration::getActive方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectConfiguration::getActive方法的具体用法?PHP ProjectConfiguration::getActive怎么用?PHP ProjectConfiguration::getActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectConfiguration
的用法示例。
在下文中一共展示了ProjectConfiguration::getActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sw_combine_debug
function sw_combine_debug()
{
if (ProjectConfiguration::getActive()->isDebug()) {
$response = sfContext::getInstance()->getResponse();
echo "<!-- DEBUG MODE - \nCombined files : \n" . var_export($response->getCombinedAssets(), 1) . "\n -->\n";
}
}
示例2: __construct
/**
* __construct
*
* @param string $options
* @return void
*/
public function __construct(array $options = array())
{
$dispatcher = ProjectConfiguration::getActive()->getEventDispatcher();
$dispatcher->connect('commentable.add_commentable_class', array($this, 'getCommentables'));
$options['generatePath'] = sfConfig::get('sf_lib_dir') . '/model/doctrine/sfCommentsPlugin';
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
}
示例3: getCommentables
public function getCommentables()
{
$dispatcher = ProjectConfiguration::getActive()->getEventDispatcher();
$event = new sfEvent($this, 'commentable.add_commentable_class');
$dispatcher->notify($event);
$commentables = $event->getReturnValue();
return $commentables ? $commentables : array();
}
示例4: preExecute
public function preExecute()
{
$this->isUserAdmin = $this->checkCredentials();
$this->tabs = sfPlop::get('sf_plop_dashboard_settings_tabs');
$this->sub = $this->getRequest()->getParameter('sub');
ProjectConfiguration::getActive()->LoadHelpers(array('I18N'));
$this->getResponse()->setTitle(sfPlop::setMetaTitle(__('Dashboard', '', 'plopAdmin')));
}
示例5: configure
public function configure()
{
// Cookie settings for increased security
ini_set('session.use_only_cookies', "1");
ini_set('session.cookie_httponly', "1");
ProjectConfiguration::getActive()->loadHelpers(array('I18N', 'OrangeDate', 'Orange', 'Url'));
sfWidgetFormSchema::setDefaultFormFormatterName('Default');
}
示例6: logMessage
/**
* Log a message.
*
* @param mixed $subject
* @param string $message
* @param string $priority
*/
public static function logMessage($subject, $message, $priority = 'info')
{
if (class_exists('ProjectConfiguration', false)) {
ProjectConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($subject, 'application.log', array($message, 'priority' => constant('sfLogger::' . strtoupper($priority)))));
} else {
$message = sprintf('{%s} %s', is_object($subject) ? get_class($subject) : $subject, $message);
sfContext::getInstance()->getLogger()->log($message, constant('SF_LOG_' . strtoupper($priority)));
}
}
示例7: extendEvent
/**
* Can be used inside a magic __call method to allow for a class to be extended
*
* This method will throw a class_name.method_not_found event,
* where class_name is the "tableized" class name.
*
* @example
* public function __call($method, $arguments)
* {
* return sfSympalExtendClass::extendEvent($this, $method, $arguments);
* }
*
* @param mixed $subject Instance of the class being extended
* @param string $method The current method being called
* @param array $arguments The arguments being passed to the above methid
*/
public static function extendEvent($subject, $method, $arguments)
{
$name = sfInflector::tableize(get_class($subject));
$event = ProjectConfiguration::getActive()->getEventDispatcher()->notifyUntil(new sfEvent($subject, $name . '.method_not_found', array('method' => $method, 'arguments' => $arguments)));
if (!$event->isProcessed()) {
throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($subject), $method));
}
return $event->getReturnValue();
}
示例8: execute
public function execute($request)
{
$this->form = new sfForm();
if (!$this->context->user->hasCredential('administrator')) {
QubitAcl::forwardUnauthorized();
}
$criteria = new Criteria();
$criteria->add(QubitSetting::NAME, 'plugins');
if (1 == count($query = QubitSetting::get($criteria))) {
$setting = $query[0];
$this->form->setDefault('enabled', unserialize($setting->__get('value', array('sourceCulture' => true))));
}
$configuration = ProjectConfiguration::getActive();
$pluginPaths = $configuration->getAllPluginPaths();
foreach (sfPluginAdminPluginConfiguration::$pluginNames as $name) {
unset($pluginPaths[$name]);
}
$this->plugins = array();
foreach ($pluginPaths as $name => $path) {
$className = $name . 'Configuration';
if (sfConfig::get('sf_plugins_dir') == substr($path, 0, strlen(sfConfig::get('sf_plugins_dir'))) && is_readable($classPath = $path . '/config/' . $className . '.class.php')) {
$this->installPluginAssets($name, $path);
require_once $classPath;
$class = new $className($configuration);
// Build a list of themes
if (isset($class::$summary) && 1 === preg_match('/theme/i', $class::$summary)) {
$this->plugins[$name] = $class;
}
}
}
if ($request->isMethod('post')) {
$this->form->setValidators(array('enabled' => new sfValidatorChoice(array('choices' => array_keys($this->plugins), 'empty_value' => array(), 'multiple' => true))));
$this->form->bind($request->getPostParameters());
if ($this->form->isValid()) {
if (1 != count($query)) {
$setting = new QubitSetting();
$setting->name = 'plugins';
}
$settings = unserialize($setting->__get('value', array('sourceCulture' => true)));
foreach (array_keys($this->plugins) as $item) {
if (in_array($item, (array) $this->form->getValue('enabled'))) {
$settings[] = $item;
} else {
if (false !== ($key = array_search($item, $settings))) {
unset($settings[$key]);
}
}
}
$setting->__set('value', serialize(array_unique($settings)));
$setting->save();
// Clear cache
$cacheClear = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
$cacheClear->run();
$this->redirect(array('module' => 'sfPluginAdminPlugin', 'action' => 'themes'));
}
}
}
示例9: execute
/**
* Displays the list of existing job queues.
*
* @param array $arguments (optional)
* @param array $options (optional)
*/
protected function execute($arguments = array(), $options = array())
{
$project = ProjectConfiguration::getActive();
$root = $project->getRootDir();
// Setting basic vars..
$model = $arguments['route_or_model'];
$name = strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\\d])([A-Z])/'), '\\1_\\2', $model));
$module = $options['module'] ? $options['module'] : $name;
$this->path = $root . "/apps/" . $arguments["application"] . "/modules/" . $module;
// Theme is always AppFlower..
$options["theme"] = "appFlower";
if (!is_dir($this->path)) {
// Reading Schema (from all plugins and the app)
if (!file_exists($root . "/config/schema.yml")) {
throw new sfCommandException("Couldn't read schema.yml!");
}
$this->schema = SchemaUtil::readSchema(true);
// Check if routing is used, and determine the model name.
$route = $this->getRouteFromName($model);
if (false !== $route) {
$options = $route->getOptions();
$model = $options["model"];
}
// Generate CRUD..
if (!$options["no-forms"]) {
$classes = array("sfPropelBuildFormsTask" => "Generating Forms & Filters..", "sfPropelBuildFiltersTask" => "");
foreach ($classes as $class => $message) {
$this->runOtherTask(array($class, $message));
}
}
$this->logBlock("Generating CRUD for " . $arguments["application"] . "/" . $module, "QUESTION");
// is it a model class name
if (!class_exists($model)) {
throw new sfCommandException(sprintf('The route "%s" does not exist and there is no "%s" class.', $model, $model));
}
$r = new ReflectionClass($model);
if (!$r->isSubclassOf('BaseObject')) {
throw new sfCommandException(sprintf('"%s" is not a Propel class.', $model));
}
$arguments["model"] = $model;
$arguments["module"] = $module;
$this->generate($arguments, $options);
$this->logBlock("Generating Widget XML data..", "QUESTION");
// Get schema data..
$data = SchemaUtil::getSchemaDataForModel($model, $this->schema);
// Generate widget XMLs..
$this->generateWidgets($data, $model, $module);
$this->logBlock("Clearing cache..", "QUESTION");
$this->runOtherTask(array("sfCacheClearTask", null));
$this->logBlock("All done!", "QUESTION");
$this->logSection("Module has been successfuly initialized!", null, null, "INFO");
$this->logSection("Please fill apps/" . $arguments["application"] . "/modules/" . $module . "/config/generator.yml to fine-tune..", null, null, "INFO");
} else {
throw new sfCommandException("Module \"" . $module . "\" alerady exists! Please fill generator.yml!");
}
}
示例10: configure
public function configure()
{
// SET DEFAULT FORM-FORMATTER
/* sfWidgetFormSchema::setDefaultFormFormatterName('bootstrap'); */
sfWidgetFormSchema::setDefaultFormFormatterName('foundation');
ProjectConfiguration::getActive()->loadHelpers( array('I18N') );
}
示例11: sw_combine_debug
function sw_combine_debug()
{
if (ProjectConfiguration::getActive()->isDebug()) {
$response = sfContext::getInstance()->getResponse();
echo "<!-- DEBUG MODE - \nCombined information : \n";
foreach ($response->getCombinedAssets() as $information) {
echo $information . "\n";
}
echo "\n-->\n";
}
}
示例12: listenToTaskCacheClearEvent
/**
* Clears thumb cache if delete_with_cc is set in app.yml
*
* @param sfEvent $event
*/
public static function listenToTaskCacheClearEvent(sfEvent $event)
{
if (!self::getProperty('zsThumb', 'delete_with_cc')) {
return;
}
/* @var $task sfTask */
$task = $event->getSubject();
//$task->runTask('thumb:clear');
$thumb_task = new zsThumbClearTask(ProjectConfiguration::getActive()->getEventDispatcher(), new sfFormatter());
$thumb_task->run();
$task->logSection('zsThumb', 'clearing...');
}
示例13: execute
/**
* Displays the list of existing job queues.
*
* @param array $arguments (optional)
* @param array $options (optional)
*/
public function execute($arguments = array(), $options = array())
{
if ($arguments["src"] === "none") {
$arguments["src"] = null;
}
if ($arguments["reporting"] != "full" && $arguments["reporting"] != "incremental" && $arguments["reporting"] != "cache" && $arguments["reporting"] != "file") {
throw new Exception("Invalid value for argument: reporting. The value 'incremental', 'cache', 'file' or 'full' are expected, but '" . $arguments["reporting"] . "' is given!");
} else {
if ($arguments["rebuild"] != "yes" && $arguments["rebuild"] != "no") {
throw new Exception("Invalid value for argument: rebuild. The value 'yes' or 'no' are expected, but '" . $arguments["rebuild"] . "' is given!");
} else {
if ($arguments["src"] != null && (!file_exists($arguments["src"]) || !is_readable($arguments["src"]))) {
throw new Exception("Invalid value for argument: src. The file '" . $arguments["src"] . "' doesn't exist or is not readable!");
}
}
}
$project = ProjectConfiguration::getActive();
$this->basedir = $project->getRootDir();
// Add plugin dirs..
$this->dirs = XmlParser::getPluginDirs($this->basedir . "/plugins");
// DB
$this->dbmanager = new sfDatabaseManager($this->configuration);
// XML Validator
$this->validator = new XmlValidator(null, false, true, $arguments["reporting"] == "cache");
// Truncating cache
if ($arguments["rebuild"] == "yes") {
afValidatorCachePeer::clearCache();
}
if ($arguments["log"] !== null) {
$this->log = $arguments["log"];
}
$this->args = $arguments;
$this->logSection("\nXML Config validation is starting.. (this may take a while)\n" . "Validation type: " . $arguments["reporting"] . " \n" . "Will flush cache: " . $arguments["rebuild"] . " ", null, null, "ERROR");
if ($arguments["reporting"] != "file" && $arguments["src"] == null) {
foreach ($this->dirs as $dir) {
$scan = substr($dir, 0, 1) == "/" ? $dir : $this->basedir . "/apps/" . $arguments['application'] . "/" . $dir;
$this->readConfigs($scan);
}
} else {
$this->validator->readXmlDocument($arguments["src"], true);
$result = $this->validator->validateXmlDocument(true);
$this->logSection($result[1] === null ? "valid: " : "error: ", $arguments["src"], null, $result[0]);
if ($result[1]) {
echo Util::arrayToString(array("file" => $tmp, "message" => $result[1]->getMessage()));
return true;
}
}
if ($arguments["reporting"] == "full") {
$this->printTotal();
}
return 0;
}
示例14: execute
/**
* Displays the list of existing job queues.
*
* @param array $arguments (optional)
* @param array $options (optional)
*/
public function execute($arguments = array(), $options = array())
{
$project = ProjectConfiguration::getActive();
$this->root = $project->getRootDir();
$this->arguments = $arguments;
$this->dirs = array($this->root . "/web");
FileUtils::getPluginDirs($this->dirs, $this->root, "/web");
$this->logSection("\nXML Generating file list.. (this may take a while)\n" . "File type: " . $arguments["ext"] . " \n", null, null, "ERROR");
foreach ($this->dirs as $dir) {
FileUtils::scanDirs($dir, "js", $this->files, true);
}
$this->printResult();
$this->finalize();
}
示例15: __construct
/**
* Constructor.
*
* @param string $name Name of the database.
*/
public function __construct($name)
{
$this->name = $name;
$finder = sfFinder::type('file')->name('*.php');
foreach ($finder->in(array_merge(ProjectConfiguration::getActive()->getPluginSubPaths('/lib/model/map'), array(sfConfig::get('sf_lib_dir') . '/model/map'))) as $path) {
require_once $path;
}
foreach (get_declared_classes() as $className) {
$class = new ReflectionClass($className);
if ($class->isSubclassOf('TableMap')) {
$this->addTableObject(new $className());
}
}
}