本文整理汇总了PHP中Director::isDev方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::isDev方法的具体用法?PHP Director::isDev怎么用?PHP Director::isDev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::isDev方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: address_to_point
/**
* Convert an address into a latitude and longitude.
*
* @param string $address The address to geocode.
* @param string $region An optional two letter region code.
* @return array An associative array with lat and lng keys.
*/
public static function address_to_point($address, $region = null)
{
// Get the URL for the Google API
$url = Config::inst()->get('GoogleGeocoding', 'google_api_url');
$key = Config::inst()->get('GoogleGeocoding', 'google_api_key');
// Query the Google API
$service = new RestfulService($url);
$service->setQueryString(array('address' => $address, 'sensor' => 'false', 'region' => $region, 'key' => $key));
if ($service->request()->getStatusCode() === 500) {
$errorMessage = '500 status code, Are you sure your SSL certificates are properly setup? You can workaround this locally by setting CURLOPT_SSL_VERIFYPEER to "false", however this is not recommended for security reasons.';
if (Director::isDev()) {
throw new Exception($errorMessage);
} else {
user_error($errorMessage);
}
return false;
}
if (!$service->request()->getBody()) {
// If blank response, ignore to avoid XML parsing errors.
return false;
}
$response = $service->request()->simpleXML();
if ($response->status != 'OK') {
return false;
}
$location = $response->result->geometry->location;
return array('lat' => (double) $location->lat, 'lng' => (double) $location->lng);
}
示例2: __call
public function __call($method, $arguments)
{
// do not make requests with an invalid key
if ($method != 'ping' && !$this->isApiKeyValid()) {
return;
}
if ($this->getAutoCache()) {
$cache_key = $this->makeCacheKey($method, $arguments);
$cache = SS_Cache::factory(__CLASS__);
if ($result = $cache->load($cache_key)) {
return unserialize($result);
}
}
try {
$result = call_user_func_array(array($this->client, $method), $arguments);
} catch (Exception $e) {
if (Director::isDev() && $this->debug_exceptions) {
var_dump($e);
}
$result = false;
}
if ($this->getAutoCache()) {
$cache->save(serialize($result));
}
return $result;
}
开发者ID:helpfulrobot,项目名称:briceburg-silverstripe-mailchimp-flexiform,代码行数:26,代码来源:FlexiFormMailChimpClient.php
示例3: isEnabled
/**
* Checks if cdn rewrite is enabled
* @return bool
*/
static function isEnabled()
{
$general = Config::inst()->get('CDNRewriteRequestFilter', 'cdn_rewrite');
$notDev = !Director::isDev() || Config::inst()->get('CDNRewriteRequestFilter', 'enable_in_dev');
$notBackend = !self::isBackend() || Config::inst()->get('CDNRewriteRequestFilter', 'enable_in_backend');
return $general && $notDev && $notBackend;
}
示例4: get_member_from_token
/**
*
*
* @param string $token
* @throws RestUserException
* @return \Member
*/
private static function get_member_from_token($token)
{
try {
$data = self::jwt_decode($token, self::get_key());
if ($data) {
// todo: check expire time
if (time() > $data['expire']) {
throw new RestUserException("Session expired", 403);
}
$id = (int) $data['userId'];
$user = \DataObject::get(\Config::inst()->get('BaseRestController', 'Owner'))->byID($id);
if (!$user) {
throw new RestUserException("Owner not found in database", 403);
}
return $user;
}
} catch (RestUserException $e) {
throw $e;
} catch (\Exception $e) {
if (\Director::isDev() && $token == \Config::inst()->get('JwtAuth', 'DevToken')) {
return \DataObject::get(\Config::inst()->get('BaseRestController', 'Owner'))->first();
}
}
throw new RestUserException("Token invalid", 403);
}
示例5: BetterNavigator
/**
* Provides a front-end utility menu with administrative functions and developer tools
* Relies on SilverStripeNavigator
*
* @return string
*/
public function BetterNavigator()
{
$isDev = Director::isDev();
if ($isDev || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
if ($this->owner && $this->owner->dataRecord) {
//Get SilverStripeNavigator links & stage info (CMS/Stage/Live/Archive)
$nav = array();
$navigator = new SilverStripeNavigator($this->owner->dataRecord);
$items = $navigator->getItems();
foreach ($items as $item) {
$nav[$item->getName()] = array('Link' => $item->getLink(), 'Active' => $item->isActive());
}
//Is the logged in member nominated as a developer?
$member = Member::currentUser();
$devs = Config::inst()->get('BetterNavigator', 'developers');
$isDeveloper = $member && is_array($devs) ? in_array($member->Email, $devs) : false;
//Add other data for template
$nav = array_merge($nav, array('Member' => $member, 'Stage' => Versioned::current_stage(), 'LoginLink' => Config::inst()->get('Security', 'login_url'), 'Mode' => Director::get_environment_type(), 'IsDeveloper' => $isDeveloper));
//Merge with page data, send to template and render
$nav = new ArrayData($nav);
$page = $this->owner->customise($nav);
return $page->renderWith('BetterNavigator');
}
}
return false;
}
示例6: requireDefaultRecords
public function requireDefaultRecords()
{
if (Director::isDev()) {
$loader = new FixtureLoader();
$loader->loadFixtures();
}
}
示例7: init
function init()
{
if (!Director::is_cli() && !Director::isDev() && !Permission::check("ADMIN")) {
Security::permissionFailure();
}
parent::init();
}
示例8: getURLPrefix
public function getURLPrefix()
{
$url = parent::getURLPrefix();
if (Director::isDev() || Director::isTest()) {
$urlarray = parse_url($url);
// define override
if (defined('DEV_SUBSITE_' . Subsite::currentSubsiteID())) {
$subsiteurl = 'DEV_SUBSITE_' . Subsite::currentSubsiteID();
return constant($subsiteurl) . $urlarray['path'];
}
if (!Subsite::currentSubsite() instanceof Subsite) {
return $url;
}
// if set in config settings
$currentDomain = Subsite::currentSubsite()->getPrimarySubsiteDomain();
if (Director::isTest()) {
$currentDomain = Subsite::currentSubsite()->TestDomainID ? Subsite::currentSubsite()->TestDomain() : $currentDomain;
}
if (Director::isDev()) {
$currentDomain = Subsite::currentSubsite()->DevDomainID ? Subsite::currentSubsite()->DevDomain() : $currentDomain;
}
if (!$currentDomain) {
return $url;
}
return $currentDomain->getFullProtocol() . $currentDomain->Domain . $urlarray['path'];
}
return $url;
}
示例9: include_requirements
/**
* Include requirements that deploynaut needs, such as javascript.
*/
public static function include_requirements()
{
// JS should always go to the bottom, otherwise there's the risk that Requirements
// puts them halfway through the page to the nearest <script> tag. We don't want that.
Requirements::set_force_js_to_bottom(true);
// todo these should be bundled into the same JS as the others in "static" below.
// We've deliberately not used combined_files as it can mess with some of the JS used
// here and cause sporadic errors.
Requirements::javascript('deploynaut/javascript/jquery.js');
Requirements::javascript('deploynaut/javascript/bootstrap.js');
Requirements::javascript('deploynaut/javascript/q.js');
Requirements::javascript('deploynaut/javascript/tablefilter.js');
Requirements::javascript('deploynaut/javascript/deploynaut.js');
Requirements::javascript('deploynaut/javascript/bootstrap.file-input.js');
Requirements::javascript('deploynaut/thirdparty/select2/dist/js/select2.min.js');
Requirements::javascript('deploynaut/javascript/selectize.js');
Requirements::javascript('deploynaut/thirdparty/bootstrap-switch/dist/js/bootstrap-switch.min.js');
Requirements::javascript('deploynaut/javascript/material.js');
// Load the buildable dependencies only if not loaded centrally.
if (!is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'static')) {
if (\Director::isDev()) {
\Requirements::javascript('deploynaut/static/bundle-debug.js');
} else {
\Requirements::javascript('deploynaut/static/bundle.js');
}
}
Requirements::css('deploynaut/static/style.css');
}
示例10: forceNonWWW
public static function forceNonWWW()
{
if (!Director::isDev() && !Director::isTest() && strpos($_SERVER['HTTP_HOST'], 'www') === 0) {
$destURL = str_replace(Director::protocol() . 'www.', Director::protocol(), Director::absoluteURL($_SERVER['REQUEST_URI']));
self::force_redirect($destURL);
}
}
示例11: XrequireDefaultRecords
public function XrequireDefaultRecords()
{
foreach ($this->config()->get('records') as $code => $record) {
if ($record['IsDev'] && Director::isDev() || $record['IsTest'] && Director::isTest() || $record['IsLive'] && Director::isLive()) {
if (!($discountType = StreakDiscountType::get_by_code($code))) {
$discountType = StreakDiscountType::create();
DB::alteration_message("Added discount type '{$code}'", "changed");
}
// if the record is using default code then update from config.
if ($code == self::DefaultCode) {
$record['Code'] = $this->config()->get('default_code');
} else {
$record['Code'] = $code;
}
$title = $record['Title'];
// if the record is using default title then update from config as hasn't changed, if different
// then leave alone
if ($title == self::DefaultTitle) {
$record['Title'] = $this->config()->get('default_title');
}
$data = array_diff_key($record, array_flip(array('IsDev', 'IsTest', 'IsLive')));
$discountType->update($data);
$discountType->write();
}
}
}
示例12: MetaTags
public function MetaTags(&$tags)
{
if (Director::isDev() or Director::isTest()) {
$tags .= '<meta name="robots" content="noindex, nofollow" />';
}
return $tags;
}
开发者ID:helpfulrobot,项目名称:nobrainerweb-silverstripe-robots-noindex,代码行数:7,代码来源:RobotsNoindexCMSExtensions.php
示例13: getFileList
protected function getFileList($fileToFind, $ext)
{
$cleanExt = "." . ltrim($ext, ".");
$fileNoExt = preg_replace("/(.min)?" . $cleanExt . "\$/", "", $fileToFind);
// If dev mode .min has less priority
return Director::isDev() ? array($fileNoExt . $cleanExt, $fileNoExt . ".min" . $cleanExt) : array($fileNoExt . ".min" . $cleanExt, $fileNoExt . $cleanExt);
}
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-gdm-extensions,代码行数:7,代码来源:SSGuru_Requirements_Backend.php
示例14: index
public function index()
{
// Prepare
ApiRequestSerialiser::execute($this);
ApiAuthenticator::execute($this);
// Generate
if ($this->status === 200) {
$output = array();
$implementerclass = $this->getImplementerClass();
if (!is_null($implementerclass)) {
$this->implementer = new $implementerclass();
$method = $this->method;
try {
$this->implementer->{$method}($this);
} catch (Exception $except) {
if ($this->status === 200) {
$this->setError(array("status" => 500, "dev" => "Error processing request: please check your syntax against the request definition", "user" => "This request could not be processed"));
}
}
} else {
if (Director::isDev()) {
$this->testOutput();
}
}
} else {
$this->populateErrorResponse();
}
// Deliver
$this->setStandardHeaders();
$ApiResponse = $this->getResponseSerialiser();
// Hook to allow analytics tracking, external logging, etc
$this->extend('updateController', $this);
return $ApiResponse->execute($this);
}
示例15: init
function init()
{
parent::init();
// Special case for dev/build: Defer permission checks to DatabaseAdmin->init() (see #4957)
$requestedDevBuild = stripos($this->request->getURL(), 'dev/build') === 0;
// We allow access to this controller regardless of live-status or ADMIN permission only
// if on CLI. Access to this controller is always allowed in "dev-mode", or of the user is ADMIN.
$canAccess = $requestedDevBuild || Director::isDev() || Director::is_cli() || Permission::check("ADMIN");
if (!$canAccess) {
return Security::permissionFailure($this);
}
// check for valid url mapping
// lacking this information can cause really nasty bugs,
// e.g. when running Director::test() from a FunctionalTest instance
global $_FILE_TO_URL_MAPPING;
if (Director::is_cli()) {
if (isset($_FILE_TO_URL_MAPPING)) {
$fullPath = $testPath = BASE_PATH;
while ($testPath && $testPath != "/" && !preg_match('/^[A-Z]:\\\\$/', $testPath)) {
$matched = false;
if (isset($_FILE_TO_URL_MAPPING[$testPath])) {
$matched = true;
break;
}
$testPath = dirname($testPath);
}
if (!$matched) {
echo 'Warning: You probably want to define ' . 'an entry in $_FILE_TO_URL_MAPPING that covers "' . Director::baseFolder() . '"' . "\n";
}
} else {
echo 'Warning: You probably want to define $_FILE_TO_URL_MAPPING in ' . 'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.org wiki' . "\n";
}
}
}