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


PHP Craft::import方法代码示例

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


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

示例1: sendMessage

 /**
  * Sends an email submitted through a contact form.
  *
  * @param ContactFormModel $message
  * @throws Exception
  * @return bool
  */
 public function sendMessage(ContactFormModel $message)
 {
     $settings = craft()->plugins->getPlugin('contactform')->getSettings();
     if (!$settings->toEmail) {
         throw new Exception('The "To Email" address is not set on the plugin’s settings page.');
     }
     // Fire an 'onBeforeSend' event
     Craft::import('plugins.contactform.events.ContactFormEvent');
     $event = new ContactFormEvent($this, array('message' => $message));
     $this->onBeforeSend($event);
     if ($event->isValid) {
         if (!$event->fakeIt) {
             $toEmails = ArrayHelper::stringToArray($settings->toEmail);
             foreach ($toEmails as $toEmail) {
                 $email = new EmailModel();
                 $emailSettings = craft()->email->getSettings();
                 $email->fromEmail = $emailSettings['emailAddress'];
                 $email->replyTo = $message->fromEmail;
                 $email->sender = $emailSettings['emailAddress'];
                 $email->fromName = $settings->prependSender . ($settings->prependSender && $message->fromName ? ' ' : '') . $message->fromName;
                 $email->toEmail = $toEmail;
                 $email->subject = $settings->prependSubject . ($settings->prependSubject && $message->subject ? ' - ' : '') . $message->subject;
                 $email->body = $message->message;
                 if ($message->attachment) {
                     $email->addAttachment($message->attachment->getTempName(), $message->attachment->getName(), 'base64', $message->attachment->getType());
                 }
                 craft()->email->sendEmail($email);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:besimhu,项目名称:CraftCMS-Boilerplate,代码行数:40,代码来源:ContactFormService.php

示例2: addTwigExtension

 public function addTwigExtension()
 {
     Craft::import('plugins.kindling.twigextensions.PathingVariablesExtension');
     Craft::import('plugins.kindling.twigextensions.CookieExtension');
     Craft::import('plugins.kindling.twigextensions.ArrayExtension');
     return [new PathingVariablesExtension(), new CookieExtension(), new ArrayExtension()];
 }
开发者ID:imarc,项目名称:craft-kindling,代码行数:7,代码来源:KindlingPlugin.php

示例3: init

 /**
  * Processes resource requests before anything else has a chance to initialize.
  */
 public function init()
 {
     // Set default timezone to UTC
     date_default_timezone_set('UTC');
     // Import all the built-in components
     foreach ($this->componentAliases as $alias) {
         Craft::import($alias);
     }
     // Initialize HttpRequestService and LogRouter right away
     $this->getComponent('request');
     $this->getComponent('log');
     // Set our own custom runtime path.
     $this->setRuntimePath($this->path->getRuntimePath());
     // Attach our own custom Logger
     Craft::setLogger(new Logger());
     // If we're not in devMode or this is a resource request, we're going to remove some logging routes.
     if (!$this->config->get('devMode') || ($resourceRequest = $this->request->isResourceRequest()) == true) {
         // If it's a resource request, we don't want any logging routes, including craft.log
         // If it's not a resource request, we'll keep the FileLogRoute around.
         if ($resourceRequest) {
             $this->log->removeRoute('FileLogRoute');
         }
         // Don't need either of these if not in devMode or it's a resource request.
         $this->log->removeRoute('WebLogRoute');
         $this->log->removeRoute('ProfileLogRoute');
     }
     parent::init();
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:31,代码来源:WebApp.php

示例4: init

 /**
  * Initializes the console app by creating the command runner.
  *
  * @return null
  */
 public function init()
 {
     // Set default timezone to UTC
     date_default_timezone_set('UTC');
     // Import all the built-in components
     foreach ($this->componentAliases as $alias) {
         Craft::import($alias);
     }
     // Attach our Craft app behavior.
     $this->attachBehavior('AppBehavior', new AppBehavior());
     // Initialize Cache and LogRouter right away (order is important)
     $this->getComponent('cache');
     $this->getComponent('log');
     // So we can try to translate Yii framework strings
     $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation'));
     // Set our own custom runtime path.
     $this->setRuntimePath(craft()->path->getRuntimePath());
     // Attach our own custom Logger
     Craft::setLogger(new Logger());
     // No need for these.
     craft()->log->removeRoute('WebLogRoute');
     craft()->log->removeRoute('ProfileLogRoute');
     // Load the plugins
     craft()->plugins->loadPlugins();
     // Validate some basics on the database configuration file.
     craft()->validateDbConfigFile();
     // Call parent::init before the plugin console command logic so craft()->commandRunner will be available to us.
     parent::init();
     foreach (craft()->plugins->getPlugins() as $plugin) {
         $commandsPath = craft()->path->getPluginsPath() . StringHelper::toLowerCase($plugin->getClassHandle()) . '/consolecommands/';
         if (IOHelper::folderExists($commandsPath)) {
             craft()->commandRunner->addCommands(rtrim($commandsPath, '/'));
         }
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:40,代码来源:ConsoleApp.php

示例5: addTwigExtension

 public function addTwigExtension()
 {
     Craft::import('plugins.minify.twigextensions.MinifyTwigExtension');
     Craft::import('plugins.minify.twigextensions.MinifyTwigTokenParser');
     Craft::import('plugins.minify.twigextensions.MinifyTwigNode');
     return new MinifyTwigExtension();
 }
开发者ID:WHITEdevelopment,项目名称:craft-minify,代码行数:7,代码来源:MinifyPlugin.php

示例6: addTwigExtension

 public function addTwigExtension()
 {
     Craft::import('plugins.venti.twigextensions.VentiTwigExtension');
     Craft::import('plugins.venti.twigextensions.Calendar_TokenParser');
     Craft::import('plugins.venti.twigextensions.Calendar_Node');
     return new VentiTwigExtension();
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:7,代码来源:VentiPlugin.php

示例7: addTwigExtension

 public function addTwigExtension()
 {
     Craft::import('plugins.foxycart.twigextensions.Hmac_Node');
     Craft::import('plugins.foxycart.twigextensions.Hmac_TokenParser');
     Craft::import('plugins.foxycart.twigextensions.FoxyCartTwigExtension');
     return new FoxyCartTwigExtension();
 }
开发者ID:digitaldevelopers,项目名称:foxycart-craft,代码行数:7,代码来源:FoxyCartPlugin.php

示例8: init

 public function init()
 {
     Craft::import('plugins.golive.tasks.GoLive_DeployTask', true);
     Craft::import('plugins.golive.etc.db.GoLive_DbBackup', true);
     Craft::import('plugins.golive.vendor.autoload', true);
     if (craft()->request->isCpRequest() && craft()->goLive_settings->isPluginEnabled()) {
         craft()->templates->includeCssResource('golive/css/golive.css');
     }
 }
开发者ID:webremote,项目名称:craft-golive,代码行数:9,代码来源:GoLivePlugin.php

示例9: init

 /**
  * Init
  *
  * @return void
  */
 public function init()
 {
     Craft::import('plugins.httpmessages.middleware.*', true);
     Craft::import('plugins.httpmessages.etc.*.*', true);
     $autoload = dirname(__FILE__) . '/../../../vendor/autoload.php';
     if (!is_file($autoload)) {
         throw new HttpMessages_Exception("`/vendor/autoload.php` could not be loaded by `craft/plugins/httpmessages/HttpMessagesPlugin.php`. Try running `composer install` in the root of the project.");
     }
     require_once $autoload;
     craft()->httpMessages_config->loadConfigFiles();
 }
开发者ID:airtype,项目名称:craft-httpmessages,代码行数:16,代码来源:HttpMessagesPlugin.php

示例10: parse

 /**
  * {@inheritDoc}
  */
 public function parse(\Twig_Token $token)
 {
     Craft::import('plugins.stow.twigextensions.Node.CacheNode');
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     $key = $this->parser->getExpressionParser()->parseExpression();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse(array($this, 'decideCacheEnd'), true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new CacheNode('', $key, $body, $lineno, $this->getTag());
 }
开发者ID:besimhu,项目名称:CraftCMS-Boilerplate,代码行数:14,代码来源:CacheTokenParser.php

示例11: init

 public function init()
 {
     Craft::import('plugins.sproutseo.helpers.SproutSeoMetaHelper');
     if (craft()->request->isSiteRequest() && !craft()->request->isLivePreview()) {
         $url = craft()->request->getUrl();
         // check if the request url needs redirect
         $redirect = sproutSeo()->redirects->getRedirect($url);
         if ($redirect) {
             craft()->request->redirect($redirect->newUrl, true, $redirect->method);
         }
     }
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:12,代码来源:SproutSeoPlugin.php

示例12: __get

 /**
  * @param string $name
  *
  * @return mixed
  */
 public function __get($name)
 {
     $plugin = craft()->plugins->getPlugin($name);
     if ($plugin && $plugin->isEnabled) {
         $pluginName = $plugin->getClassHandle();
         $className = __NAMESPACE__ . '\\' . $pluginName . 'Variable';
         // Variables should already be imported by the plugin service, but let's double check.
         if (!class_exists($className)) {
             Craft::import('plugins.' . StringHelper::toLowerCase($pluginName) . '.variables.' . $pluginName . 'Variable');
         }
         return new $className();
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:18,代码来源:CraftVariable.php

示例13: parse

 public function parse(\Twig_Token $token)
 {
     Craft::import('plugins.premailer.twigextensions.Node.Premailer_Node');
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     $nodes = array("body" => null, "options" => null);
     $attributes = array();
     if ($stream->test(\Twig_Token::NAME_TYPE, 'with')) {
         $stream->next();
         $nodes['options'] = $this->parser->getExpressionParser()->parseExpression();
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $nodes['body'] = $this->parser->subparse(array($this, 'decidePremailerEnd'), true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new Premailer_Node($nodes, $attributes, $lineno, $this->getTag());
 }
开发者ID:webremote,项目名称:Craft-Plugin---Premailer,代码行数:16,代码来源:Premailer_TokenParser.php

示例14: init

 public function init()
 {
     Craft::import('plugins.supercooltools.tools.*');
     if (craft()->request->isCpRequest() && craft()->userSession->isLoggedIn()) {
         craft()->templates->includeCssResource('supercooltools/css/supercooltools.css');
         craft()->templates->includeJsResource('supercooltools/js/supercooltools.js');
         if (craft()->config->get('openInstructionLinksInNewWindow', 'SupercoolTools')) {
             craft()->templates->includeJs('new SupercoolTools.TargetBlankInstructionLinks();');
         }
         craft()->templates->includeJsFile('//assets.zendesk.com/embeddable_framework/main.js');
         $zendeskHandle = craft()->config->get('zendeskHandle', 'SupercoolTools');
         if (!is_null($zendeskHandle)) {
             craft()->templates->includeJs('new SupercoolTools.Zendesk("' . $zendeskHandle . '");');
         }
     }
 }
开发者ID:supercool,项目名称:Tools,代码行数:16,代码来源:SupercoolToolsPlugin.php

示例15: init

 /**
  *
  */
 public function init()
 {
     // Set default timezone to UTC
     date_default_timezone_set('UTC');
     foreach ($this->componentAliases as $alias) {
         Craft::import($alias);
     }
     craft()->getComponent('log');
     // Set our own custom runtime path.
     $this->setRuntimePath(craft()->path->getRuntimePath());
     // No need for these.
     craft()->log->removeRoute('WebLogRoute');
     craft()->log->removeRoute('ProfileLogRoute');
     // Load the plugins
     craft()->plugins->loadPlugins();
     parent::init();
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:20,代码来源:ConsoleApp.php


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