本文整理汇总了PHP中false类的典型用法代码示例。如果您正苦于以下问题:PHP false类的具体用法?PHP false怎么用?PHP false使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了false类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDevice
/**
* Get device features
*
* @return Application_Model_Device
*/
public function getDevice()
{
if ($this->device == null) {
$this->device = false;
$devices = Application_Model_DevicesMapper::i()->fetchAll();
/* @var Application_Model_Device $device */
foreach ($devices as $device) {
// if exact do an == comparison
if ($device->isExact() && $device->getPattern() == $_SERVER['HTTP_USER_AGENT'] || !$device->isExact() && preg_match($device->getPattern(), $_SERVER['HTTP_USER_AGENT']) > 0) {
// valid $device found;
$this->device = $device;
break;
}
}
if ($this->device == false) {
// load things from default
$this->device = new Application_Model_Device();
if (X_VlcShares_Plugins::broker()->isRegistered('wiimc')) {
$this->device->setGuiClass($this->options->get('gui', 'X_VlcShares_Plugins_WiimcPlxRenderer'));
} else {
$this->device->setGuiClass($this->options->get('gui', 'X_VlcShares_Plugins_WebkitRenderer'));
}
$this->device->setIdProfile($this->options->get('profile', 1))->setLabel("Unknown device");
}
}
return $this->device;
}
示例2: pullApiKey
/**
* @return bool|\Dingo\Api\Models\ApiKey
*/
protected function pullApiKey()
{
$headers = ['ID', 'Service', 'Name', 'Token'];
$this->table($headers, $this->user->apiKeys()->get(['id', 'service', 'name', 'token']));
$key_id = $this->ask('What key are we using?');
if ($key_id === 'exit') {
exit;
}
if ($key = $this->user->apiKeys()->where('id', $key_id)->first()) {
return $key;
}
$this->error('ApiKey ' . $key_id . ' not found!');
return false;
}
示例3: __construct
/**
* Migrate constructor
*
* @param string $dirname module directory name that defines the tables to be migrated
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function __construct($dirname)
{
$this->helper = Helper::getHelper($dirname);
if (false === $this->helper) {
throw new \InvalidArgumentException("Invalid module {$dirname} specified");
}
$module = $this->helper->getModule();
$this->moduleTables = $module->getInfo('tables');
if (empty($this->moduleTables)) {
throw new \RuntimeException("No tables established in module");
}
$version = $module->getInfo('version');
$this->tableDefinitionFile = $this->helper->path("sql/{$dirname}_{$version}_migrate.yml");
$this->tableHandler = new Tables();
}
示例4: storeImage
/**
* Save image information to DB.
*
* @param \Magento\Catalog\Model\Product $product
* @param array $images
* @return void
*/
protected function storeImage($product, $images)
{
$baseImage = '';
$i = 1;
$mediaAttribute = $this->eavConfig->getAttribute('catalog_product', 'media_gallery');
foreach ($images as $image) {
if (empty($image)) {
$this->errors[] = $product->getSku();
continue;
}
if (strpos($image, '_main') !== false) {
$baseImage = $image;
}
$id = $this->galleryResource->insertGallery(['attribute_id' => $mediaAttribute->getAttributeId(), 'entity_id' => $product->getId(), 'value' => $image]);
$this->galleryResource->insertGalleryValueInStore(['value_id' => $id, 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, 'entity_id' => $product->getId(), 'label' => 'Image', 'position' => $i, 'disables' => 0]);
$this->galleryResource->bindValueToEntity($id, $product->getId());
$i++;
}
if (empty($baseImage)) {
$baseImage = $images[0];
}
if ($baseImage) {
$imageAttribute = $product->getResource()->getAttribute('image');
$smallImageAttribute = $product->getResource()->getAttribute('small_image');
$thumbnailAttribute = $product->getResource()->getAttribute('thumbnail');
$adapter = $product->getResource()->getConnection();
foreach ([$imageAttribute, $smallImageAttribute, $thumbnailAttribute] as $attribute) {
$table = $imageAttribute->getBackend()->getTable();
/** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter*/
$data = [$attribute->getBackend()->getEntityIdField() => $product->getId(), 'attribute_id' => $attribute->getId(), 'value' => $baseImage];
$adapter->insertOnDuplicate($table, $data, ['value']);
}
}
}
示例5: getSite
/**
* Returns the site with provided global id, or false if there is no such site.
*
* @since 1.21
*
* @param string $globalId
* @param string $source
*
* @return Site|false
*/
public function getSite($globalId, $source = 'cache')
{
if ($source === 'cache' && $this->sites !== false) {
return $this->sites->hasSite($globalId) ? $this->sites->getSite($globalId) : false;
}
return SitesTable::singleton()->selectRow(null, array('global_key' => $globalId));
}
示例6: send
/**
* Send a mail using this transport
*
* @param \Zend\Mail\Mail $mail
* @access public
* @return void
* @throws \Zend\Mail\Transport\Exception if mail is empty
*/
public function send(\Zend\Mail\Mail $mail)
{
$this->_isMultipart = false;
$this->_mail = $mail;
$this->_parts = $mail->getParts();
$mime = $mail->getMime();
// Build body content
$this->_buildBody();
// Determine number of parts and boundary
$count = count($this->_parts);
$boundary = null;
if ($count < 1) {
throw new Exception('Empty mail cannot be sent');
}
if ($count > 1) {
// Multipart message; create new MIME object and boundary
$mime = new Mime\Mime($this->_mail->getMimeBoundary());
$boundary = $mime->boundary();
} elseif ($this->_isMultipart) {
// multipart/alternative -- grab boundary
$boundary = $this->_parts[0]->boundary;
}
// Determine recipients, and prepare headers
$this->recipients = implode(',', $mail->getRecipients());
$this->_prepareHeaders($this->_getHeaders($boundary));
// Create message body
// This is done so that the same \Zend\Mail\Mail object can be used in
// multiple transports
$message = new Mime\Message();
$message->setParts($this->_parts);
$message->setMime($mime);
$this->body = $message->generateMessage($this->EOL);
// Send to transport!
$this->_sendMail();
}
示例7: log
private static function log($level, $string, $statsLog = false)
{
if (php_sapi_name() === 'cli' || defined('STDIN')) {
// we are being executed from the CLI, nowhere to log
return;
}
if (self::$loggingHandler === null) {
// Initialize logging
self::createLoggingHandler();
if (!empty(self::$earlyLog)) {
error_log('----------------------------------------------------------------------');
// output messages which were logged before we properly initialized logging
foreach (self::$earlyLog as $msg) {
self::log($msg['level'], $msg['string'], $msg['statsLog']);
}
}
} elseif (self::$loggingHandler === false) {
// some error occurred while initializing logging
if (empty(self::$earlyLog)) {
// this is the first message
error_log('--- Log message(s) while initializing logging ------------------------');
}
error_log($string);
self::defer($level, $string, $statsLog);
return;
}
if (self::$captureLog) {
$ts = microtime(true);
$msecs = (int) (($ts - (int) $ts) * 1000);
$ts = GMdate('H:i:s', $ts) . sprintf('.%03d', $msecs) . 'Z';
self::$capturedLog[] = $ts . ' ' . $string;
}
if (self::$logLevel >= $level || $statsLog) {
if (is_array($string)) {
$string = implode(",", $string);
}
$formats = array('%trackid', '%msg', '%srcip', '%stat');
$replacements = array(self::$trackid, $string, $_SERVER['REMOTE_ADDR']);
$stat = '';
if ($statsLog) {
$stat = 'STAT ';
}
array_push($replacements, $stat);
if (self::$trackid === self::NO_TRACKID && !self::$shuttingDown) {
// we have a log without track ID and we are not still shutting down, so defer logging
self::defer($level, $string, $statsLog);
return;
} elseif (self::$trackid === self::NO_TRACKID) {
// shutting down without a track ID, prettify it
array_shift($replacements);
array_unshift($replacements, 'N/A');
}
// we either have a track ID or we are shutting down, so just log the message
$string = str_replace($formats, $replacements, self::$format);
self::$loggingHandler->log($level, $string);
}
}
示例8: valid
/**
* Checks if current position is valid.
*
* @return bool Returns true on success, false otherwise
*/
public function valid()
{
if (is_null($this->current)) {
return !empty($this->branch);
}
if ($this->current instanceof RecursiveLeafInterface) {
return $this->current->valid();
}
return false;
}
示例9: show
/**
* Show the template to the user.
*/
public function show()
{
if ($this->twig !== false) {
$this->twigDefaultContext();
echo $this->twig->render($this->twig_template, $this->data);
} else {
$filename = $this->findTemplatePath($this->template);
require $filename;
}
}
示例10: purge
/**
* Purges the cache store, and loader if there is one.
*
* @return bool True on success, false otherwise
*/
public function purge()
{
// 1. Purge the persist cache.
$this->persistcache = array();
// 2. Purge the store.
$this->store->purge();
// 3. Optionally pruge any stacked loaders.
if ($this->loader) {
$this->loader->purge();
}
return true;
}
示例11: purge
/**
* Purges the cache store, and loader if there is one.
*
* @return bool True on success, false otherwise
*/
public function purge()
{
// 1. Purge the static acceleration array.
$this->static_acceleration_purge();
// 2. Purge the store.
$this->store->purge();
// 3. Optionally pruge any stacked loaders.
if ($this->loader) {
$this->loader->purge();
}
return true;
}
示例12: send
/**
* Send a mail using this transport
*
* @param OpenPGP_Zend_Mail $mail
* @access public
* @return void
* @throws Zend_Mail_Transport_Exception if mail is empty
*/
public function send(OpenPGP_Zend_Mail $mail)
{
$this->_isMultipart = false;
$this->_mail = $mail;
$this->_parts = $mail->getParts();
$mime = $mail->getMime();
// Build body content
$this->_buildBody();
// Determine number of parts and boundary
$count = count($this->_parts);
$boundary = null;
if ($count < 1) {
throw new Zend_Mail_Transport_Exception('Empty mail cannot be sent');
}
if ($count > 1) {
// Multipart message; create new MIME object and boundary
$mime = new Zend_Mime($this->_mail->getMimeBoundary());
$boundary = $mime->boundary();
} elseif ($this->_isMultipart) {
// multipart/alternative -- grab boundary
$boundary = $this->_parts[0]->boundary;
}
// Determine recipients, and prepare headers
$this->recipients = implode(',', $mail->getRecipients());
$this->_prepareHeaders($this->_getHeaders($boundary));
// Create message body
// This is done so that the same OpenPGP_Zend_Mail object can be used in
// multiple transports
$message = new Zend_Mime_Message();
$message->setParts($this->_parts);
$message->setMime($mime);
$this->body = $message->generateMessage($this->EOL);
////////////////////////////////////////////////////////
// //
// ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION //
// USING lib/openpgp/opepgplib.php //
// //
////////////////////////////////////////////////////////
// get from globals (set in tiki-setup.php)
global $openpgplib;
$pgpmime_msg = $openpgplib->prepareEncryptWithZendMail($this->header, $this->body, $mail->getRecipients());
$this->header = $pgpmime_msg[0];
// set pgp/mime headers from result array
$this->body = $pgpmime_msg[1];
// set pgp/mime encrypted message body from result array
////////////////////////////////////////////////////////
// //
// ALPHAFIELDS 2012-11-03: ..END PGP/MIME ENCRYPTION //
// //
////////////////////////////////////////////////////////
// Send to transport!
$this->_sendMail();
}
示例13: handleException
/**
* Handle exception (uncatched).
*
* @param \Throwable $exception
*/
public function handleException($exception)
{
if (!$exception instanceof \Exception) {
$exception = new \Exception("Can't handle exception thrown!");
}
// Log
\Logger::error((string) $exception);
// Whoops
if ($this->whoops !== false) {
$this->whoops->handleException($exception);
}
}
示例14: run
/**
* @param string $keyword
* @param int $keywordAdditionalWeight
*/
public function run($keyword, $keywordAdditionalWeight = 0)
{
if ($this->_databaseConnection) {
$prefix = config('coaster::blog.prefix');
$blogPosts = $this->_databaseConnection->query("\n SELECT wp.*, weights.search_weight FROM wp_posts wp RIGHT JOIN\n (\n SELECT ID, sum(search_weight) as search_weight\n FROM (\n SELECT ID, 4 AS search_weight FROM {$prefix}posts WHERE post_type = 'post' AND post_status = 'publish' AND post_title like '%" . $keyword . "%'\n UNION\n SELECT ID, 2 AS search_weight FROM {$prefix}posts WHERE post_type = 'post' AND post_status = 'publish' AND post_content like '%" . $keyword . "%'\n ) results\n GROUP BY ID\n ) weights\n ON weights.ID = wp.ID;\n ");
if ($blogPosts) {
$defaultSeparator = new Path(false);
foreach ($blogPosts as $blogPost) {
$postData = new \stdClass();
$postData->id = 'WP' . $blogPost['ID'];
unset($blogPost['ID']);
foreach ($blogPost as $field => $value) {
$postData->{$field} = $value;
}
$postData->content = $blogPost['post_content'];
$postData->fullName = ucwords(str_replace('/', ' ', config('coaster::blog.url'))) . $defaultSeparator->separator . $blogPost['post_title'];
$postData->fullUrl = config('coaster::blog.url') . $blogPost['post_name'];
self::_addWeight($postData, $blogPost['search_weight'] + $keywordAdditionalWeight);
}
}
}
}
示例15: get_required_option_bool
/**
* Checks if login is required on this site. is_required for public access
*
* @since 0.1.0
*
* @return boolean Enabled or disabled
*/
protected function get_required_option_bool()
{
$setting = $this->get_option('require');
if ('enabled' === $setting) {
return true;
}
if ('disabled' === $setting) {
return false;
}
if ($this->network_admin) {
return (bool) $this->network_admin->get_option('enable_network_wide');
}
return false;
}