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


PHP Craft::app方法代码示例

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


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

示例1: getService

 /**
  * @return SproutEmail_DefaultMailerService
  */
 public function getService()
 {
     if (is_null($this->service)) {
         $this->service = Craft::app()->getComponent('sproutEmail_defaultMailer');
     }
     return $this->service;
 }
开发者ID:jackmcgreevy,项目名称:fast,代码行数:10,代码来源:SproutEmailDefaultMailer.php

示例2: init

 public function init()
 {
     parent::init();
     $this->mailers = Craft::app()->getComponent('sproutEmail_mailer');
     $this->entries = Craft::app()->getComponent('sproutEmail_entries');
     $this->campaigns = Craft::app()->getComponent('sproutEmail_campaigns');
     $this->notifications = Craft::app()->getComponent('sproutEmail_notifications');
 }
开发者ID:jackmcgreevy,项目名称:fast,代码行数:8,代码来源:SproutEmailService.php

示例3: init

 public function init()
 {
     parent::init();
     $this->link = Craft::app()->getComponent('sproutFields_linkField');
     $this->email = Craft::app()->getComponent('sproutFields_emailField');
     $this->emailSelect = Craft::app()->getComponent('sproutFields_emailSelectField');
     $this->phone = Craft::app()->getComponent('sproutFields_phoneField');
 }
开发者ID:andyra,项目名称:tes,代码行数:8,代码来源:SproutFieldsService.php

示例4: init

 public function init()
 {
     parent::init();
     $this->entries = Craft::app()->getComponent('sproutForms_entries');
     $this->fields = Craft::app()->getComponent('sproutForms_fields');
     $this->forms = Craft::app()->getComponent('sproutForms_forms');
     $this->groups = Craft::app()->getComponent('sproutForms_groups');
     $this->settings = Craft::app()->getComponent('sproutForms_settings');
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:9,代码来源:SproutFormsService.php

示例5: init

 public function init()
 {
     parent::init();
     $this->meta = Craft::app()->getComponent('sproutSeo_meta');
     $this->defaults = Craft::app()->getComponent('sproutSeo_metaDefaults');
     $this->overrides = Craft::app()->getComponent('sproutSeo_metaOverrides');
     $this->sitemap = Craft::app()->getComponent('sproutSeo_sitemap');
     $this->settings = Craft::app()->getComponent('sproutSeo_settings');
     $this->redirects = Craft::app()->getComponent('sproutSeo_redirects');
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:10,代码来源:SproutSeoService.php

示例6: patrol

/**
 * Returns an instance of the Patrol service and enables proper hinting and service layer encapsulation
 *
 * @return PatrolService
 */
function patrol()
{
    return Craft::app()->getComponent('patrol');
}
开发者ID:transomdesign,项目名称:transom-craft-starter,代码行数:9,代码来源:PatrolPlugin.php

示例7: doxter

/**
 * Enables us to have a single point of access to our service layer and proper hinting
 *
 * @return DoxterService
 */
function doxter()
{
    return Craft::app()->getComponent('doxter');
}
开发者ID:kamicrafted,项目名称:designhub,代码行数:9,代码来源:DoxterPlugin.php

示例8: craft

/**
 * Returns the current craft() instance. This is a wrapper function for the Craft::app() instance.
 *
 * @return WebApp|ConsoleApp
 */
function craft()
{
    return Craft::app();
}
开发者ID:jmstan,项目名称:craft-website,代码行数:9,代码来源:Craft.php

示例9: sendFile

 /**
  * Sends a file to the user.
  *
  * We’re overriding this from {@link \CHttpRequest::sendFile()} so we can have more control over the headers.
  *
  * @param string     $path      The path to the file on the server.
  * @param string     $content   The contents of the file.
  * @param array|null $options   An array of optional options. Possible keys include 'forceDownload', 'mimeType',
  *                              and 'cache'.
  * @param bool|null  $terminate Whether the request should be terminated after the file has been sent.
  *                              Defaults to `true`.
  *
  * @throws HttpException
  * @return null
  */
 public function sendFile($path, $content, $options = array(), $terminate = true)
 {
     $fileName = IOHelper::getFileName($path, true);
     // Clear the output buffer to prevent corrupt downloads. Need to check the OB status first, or else some PHP
     // versions will throw an E_NOTICE since we have a custom error handler
     // (http://pear.php.net/bugs/bug.php?id=9670)
     if (ob_get_length() !== false) {
         // If zlib.output_compression is enabled, then ob_clean() will corrupt the results of output buffering.
         // ob_end_clean is what we want.
         ob_end_clean();
     }
     // Default to disposition to 'download'
     $forceDownload = !isset($options['forceDownload']) || $options['forceDownload'];
     if ($forceDownload) {
         HeaderHelper::setDownload($fileName);
     }
     if (empty($options['mimeType'])) {
         if (($options['mimeType'] = \CFileHelper::getMimeTypeByExtension($fileName)) === null) {
             $options['mimeType'] = 'text/plain';
         }
     }
     HeaderHelper::setHeader(array('Content-Type' => $options['mimeType'] . '; charset=utf-8'));
     $fileSize = mb_strlen($content, '8bit');
     $contentStart = 0;
     $contentEnd = $fileSize - 1;
     $httpVersion = $this->getHttpVersion();
     if (isset($_SERVER['HTTP_RANGE'])) {
         HeaderHelper::setHeader(array('Accept-Ranges' => 'bytes'));
         // Client sent us a multibyte range, can not hold this one for now
         if (mb_strpos($_SERVER['HTTP_RANGE'], ',') !== false) {
             HeaderHelper::setHeader(array('Content-Range' => 'bytes ' . $contentStart - $contentEnd / $fileSize));
             throw new HttpException(416, 'Requested Range Not Satisfiable');
         }
         $range = str_replace('bytes=', '', $_SERVER['HTTP_RANGE']);
         // range requests starts from "-", so it means that data must be dumped the end point.
         if ($range[0] === '-') {
             $contentStart = $fileSize - mb_substr($range, 1);
         } else {
             $range = explode('-', $range);
             $contentStart = $range[0];
             // check if the last-byte-pos presents in header
             if (isset($range[1]) && is_numeric($range[1])) {
                 $contentEnd = $range[1];
             }
         }
         // Check the range and make sure it's treated according to the specs.
         // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
         // End bytes can not be larger than $end.
         $contentEnd = $contentEnd > $fileSize ? $fileSize - 1 : $contentEnd;
         // Validate the requested range and return an error if it's not correct.
         $wrongContentStart = $contentStart > $contentEnd || $contentStart > $fileSize - 1 || $contentStart < 0;
         if ($wrongContentStart) {
             HeaderHelper::setHeader(array('Content-Range' => 'bytes ' . $contentStart - $contentEnd / $fileSize));
             throw new HttpException(416, 'Requested Range Not Satisfiable');
         }
         HeaderHelper::setHeader("HTTP/{$httpVersion} 206 Partial Content");
         HeaderHelper::setHeader(array('Content-Range' => 'bytes ' . $contentStart - $contentEnd / $fileSize));
     } else {
         HeaderHelper::setHeader("HTTP/{$httpVersion} 200 OK");
     }
     // Calculate new content length
     $length = $contentEnd - $contentStart + 1;
     if (!empty($options['cache'])) {
         $cacheTime = 31536000;
         // 1 year
         HeaderHelper::setHeader(array('Expires' => gmdate('D, d M Y H:i:s', time() + $cacheTime) . ' GMT'));
         HeaderHelper::setHeader(array('Pragma' => 'cache'));
         HeaderHelper::setHeader(array('Cache-Control' => 'max-age=' . $cacheTime));
         $modifiedTime = IOHelper::getLastTimeModified($path);
         HeaderHelper::setHeader(array('Last-Modified' => gmdate("D, d M Y H:i:s", $modifiedTime->getTimestamp()) . ' GMT'));
     } else {
         if (!$forceDownload) {
             HeaderHelper::setNoCache();
         } else {
             // Fixes a bug in IE 6, 7 and 8 when trying to force download a file over SSL:
             // https://stackoverflow.com/questions/1218925/php-script-to-download-file-not-working-in-ie
             HeaderHelper::setHeader(array('Pragma' => '', 'Cache-Control' => ''));
         }
     }
     if ($options['mimeType'] == 'application/x-javascript' || $options['mimeType'] == 'text/css') {
         HeaderHelper::setHeader(array('Vary' => 'Accept-Encoding'));
     }
     if (!ob_get_length()) {
         HeaderHelper::setLength($length);
     }
//.........这里部分代码省略.........
开发者ID:nathanedwards,项目名称:cowfields.craft,代码行数:101,代码来源:HttpRequestService.php

示例10: sproutEmailDefaultMailer

/**
 * @return SproutEmail_DefaultMailerService
 */
function sproutEmailDefaultMailer()
{
    return Craft::app()->getComponent('sproutEmail_defaultMailer');
}
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:7,代码来源:SproutEmailPlugin.php

示例11: sproutForms

/**
 * @return SproutFormsService
 */
function sproutForms()
{
    return Craft::app()->getComponent('sproutForms');
}
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:7,代码来源:SproutFormsPlugin.php

示例12: sproutSeo

/**
 * @return SproutSeoService
 */
function sproutSeo()
{
    return Craft::app()->getComponent('sproutSeo');
}
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:7,代码来源:SproutSeoPlugin.php

示例13: sendFile

 /**
  * Sends a file to the user.
  *
  * We're overriding this from \CHttpRequest so we can have more control over the headers.
  *
  * @param string $path
  * @param string $content
  * @param array|null $options
  * @param bool|null $terminate
  */
 public function sendFile($path, $content, $options = array(), $terminate = true)
 {
     $fileName = IOHelper::getFileName($path, true);
     // Clear the output buffer to prevent corrupt downloads.
     // Need to check the OB status first, or else some PHP versions will throw an E_NOTICE since we have a custom error handler
     // (http://pear.php.net/bugs/bug.php?id=9670)
     if (ob_get_length() !== false) {
         ob_clean();
     }
     // Default to disposition to 'download'
     if (!isset($options['forceDownload']) || $options['forceDownload']) {
         header('Content-Disposition: attachment; filename="' . $fileName . '"');
     }
     if (empty($options['mimeType'])) {
         if (($options['mimeType'] = \CFileHelper::getMimeTypeByExtension($fileName)) === null) {
             $options['mimeType'] = 'text/plain';
         }
     }
     header('Content-type: ' . $options['mimeType']);
     if (!empty($options['cache'])) {
         $cacheTime = 31536000;
         // 1 year
         header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cacheTime) . ' GMT');
         header('Pragma: cache');
         header('Cache-Control: max-age=' . $cacheTime);
         $modifiedTime = IOHelper::getLastTimeModified($path);
         header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $modifiedTime->getTimestamp()) . ' GMT');
     } else {
         header('Pragma: public');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     }
     if (!ob_get_length()) {
         header('Content-Length: ' . (function_exists('mb_strlen') ? mb_strlen($content, '8bit') : strlen($content)));
     }
     if ($options['mimeType'] == 'application/x-javascript' || $options['mimeType'] == 'text/css') {
         header('Vary: Accept-Encoding');
     }
     if ($terminate) {
         // clean up the application first because the file downloading could take long time
         // which may cause timeout of some resources (such as DB connection)
         ob_start();
         Craft::app()->end(0, false);
         ob_end_clean();
         echo $content;
         exit(0);
     } else {
         echo $content;
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:60,代码来源:HttpRequestService.php


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