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


PHP Wire类代码示例

本文整理汇总了PHP中Wire的典型用法代码示例。如果您正苦于以下问题:PHP Wire类的具体用法?PHP Wire怎么用?PHP Wire使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: returnsCachedSignal

 /**
  * @test
  * @covers ::getSignal
  * @covers \Hamdrew\AdventOfCode\Day7\CircuitComponent::getSignal
  * @covers \Hamdrew\AdventOfCode\Day7\CircuitComponent::setSignal
  */
 public function returnsCachedSignal()
 {
     $signal = 123;
     $source = \Mockery::mock('\\Hamdrew\\AdventOfCode\\Day7\\CircuitComponent')->shouldReceive('getSignal')->andReturn($signal)->once()->getMock();
     $wire = new Wire('test', $source);
     $wire->getSignal();
     $this->assertSame($signal, $wire->getSignal());
 }
开发者ID:hamdrew,项目名称:adventofcode,代码行数:14,代码来源:WireTest.php

示例2: getHooksInfo

 /**
  * Get hooks debug info for the given Wire object
  * 
  * @param Wire $obj
  * @return array
  * 
  */
 public function getHooksInfo(Wire $obj)
 {
     $hooks = array();
     foreach ($obj->getHooks() as $hook) {
         list($class, $priority) = explode(':', $hook['id']);
         $key = '';
         $value = '';
         if ($hook['options']['before']) {
             $key .= "before ";
         }
         if ($hook['options']['type'] == 'property') {
             $key .= "property ";
         } else {
             if ($hook['options']['after']) {
                 if (method_exists($class, $hook['method']) || method_exists($class, '___' . $hook['method'])) {
                     $key .= "after ";
                 }
             }
         }
         if ($hook['options']['type'] == 'property' || !$hook['options']['allInstances']) {
             $key .= "{$class}" . '->' . "{$hook['method']}";
         } else {
             $key .= "{$class}::{$hook['method']}";
         }
         $filename = '';
         if (!empty($hook['toObject'])) {
             $value .= $hook['toObject']->className() . "->";
             $ref = new ReflectionClass($hook['toObject']);
             $filename = $ref->getFileName();
         }
         if (!empty($hook['toMethod'])) {
             if (is_string($hook['toMethod'])) {
                 $value .= "{$hook['toMethod']}()";
             } else {
                 if (is_callable($hook['toMethod'])) {
                     $ref = new ReflectionFunction($hook['toMethod']);
                     $filename = $ref->getFileName();
                     $value = "anonymous function()";
                 }
             }
         }
         if ($filename) {
             $value .= " in " . basename($filename);
         }
         if (!isset($hooks[$key])) {
             $hooks[$key] = $value;
         } else {
             if (!is_array($hooks[$key])) {
                 $hooks[$key] = array($hooks[$key]);
             }
             $hooks[$key][] = $value;
         }
     }
     return $hooks;
 }
开发者ID:Rizsti,项目名称:Processwire_Compatibility,代码行数:62,代码来源:WireDebugInfo.php

示例3: fuel

/**
 * Return all Fuel, or specified ProcessWire API variable, or NULL if it doesn't exist.
 *
 * Same as Wire::getFuel($name) and Wire::getAllFuel();
 * When a $name is specified, this function is identical to the wire() function.
 * Both functions exist more for consistent naming depending on usage. 
 *
 * @param string $name If ommitted, returns a Fuel object with references to all the fuel.
 * @return mixed Fuel value if available, NULL if not. 
 *
 */
function fuel($name = '')
{
    if (!$name) {
        return Wire::getAllFuel();
    }
    return Wire::getFuel($name);
}
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:18,代码来源:Functions.php

示例4: __

/**
 * Perform a language translation
 * 
 * @param string $text Text for translation. 
 * @param string $textdomain Textdomain for the text, may be class name, filename, or something made up by you. If ommitted, a debug backtrace will attempt to determine it automatically.
 * @param string $context Name of context - DO NOT USE with this function for translation as it won't be parsed for translation. Use only with the _x() function, which will be parsed. 
 * @return string Translated text or original text if translation not available.
 *
 *
 */
function __($text, $textdomain = null, $context = '')
{
    if (!Wire::getFuel('languages')) {
        return $text;
    }
    if (!($language = Wire::getFuel('user')->language)) {
        return $text;
    }
    if (!$language->id) {
        return $text;
    }
    if (is_null($textdomain)) {
        $traces = @debug_backtrace(defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
        if (isset($traces[0]) && $traces[0]['file'] != __FILE__) {
            $textdomain = $traces[0]['file'];
        } else {
            if (isset($traces[1]) && $traces[1]['file'] != __FILE__) {
                $textdomain = $traces[1]['file'];
            }
        }
        if (is_null($textdomain)) {
            $textdomain = 'site';
        }
    }
    return htmlspecialchars($language->translator()->getTranslation($textdomain, $text, $context), ENT_QUOTES, 'UTF-8');
}
开发者ID:rzelnik,项目名称:ProcessWire,代码行数:36,代码来源:LanguageFunctions.php

示例5: setFuel

 /**
  * Add fuel to all classes descending from Wire
  *
  * @param string $name 
  * @param mixed $value 
  *
  */
 public static function setFuel($name, $value)
 {
     if (is_null(self::$fuel)) {
         self::$fuel = new Fuel();
     }
     self::$fuel->set($name, $value);
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:14,代码来源:Wire.php

示例6: setCurrentUser

 public function setCurrentUser(User $user)
 {
     if (!$user->roles->has("id=" . $this->fuel('config')->guestUserRolePageID)) {
         $guestRole = $this->fuel('roles')->getGuestRole();
         $user->roles->add($guestRole);
     }
     $this->currentUser = $user;
     Wire::setFuel('user', $user);
 }
开发者ID:nightsh,项目名称:ProcessWire,代码行数:9,代码来源:Users.php

示例7: __

/**
 * Perform a language translation
 *
 * If no context provided then a global context is assumed
 *
 */
function __($context, $text = null)
{
    if (is_null($text)) {
        $text = $context;
        $context = null;
    }
    if (!Wire::getFuel('languages')) {
        return $text;
    }
    if (!($language = Wire::getFuel('user')->language)) {
        return $text;
    }
    return $language->translator()->getTranslation($context, $text);
}
开发者ID:nicolasleon,项目名称:P21,代码行数:20,代码来源:Functions.php

示例8: setCurrentUser

 /**
  * Set the current system user (the $user API variable)
  *
  * @param User $user
  *
  */
 public function setCurrentUser(User $user)
 {
     $hasGuest = false;
     $guestRoleID = $this->wire('config')->guestUserRolePageID;
     if ($user->roles) {
         foreach ($user->roles as $role) {
             if ($role->id == $guestRoleID) {
                 $hasGuest = true;
                 break;
             }
         }
     }
     if (!$hasGuest && $user->roles) {
         $guestRole = $this->wire('roles')->getGuestRole();
         $user->roles->add($guestRole);
     }
     $this->currentUser = $user;
     Wire::setFuel('user', $user);
 }
开发者ID:avatar382,项目名称:fablab_site,代码行数:25,代码来源:Users.php

示例9: isHooked

 /**
  * Returns true if the method/property hooked, false if it isn't.
  *
  * This is for optimization use. It does not distinguish about class instance. 
  * It only distinguishes about class if you provide a class with the $method argument (i.e. Class::).
  * As a result, a true return value indicates something "might" be hooked, as opposed to be 
  * being definitely hooked. 
  *
  * If checking for a hooked method, it should be in the form "Class::method()" or "method()". 
  * If checking for a hooked property, it should be in the form "Class::property" or "property". 
  * 
  * @param string $method Method or property name in one of the following formats:
  * 	Class::method()
  * 	Class::property
  * 	method()
  * 	property
  * @param Wire|null $instance Optional instance to check against (see isThisHooked method for details)
  * 	Note that if specifying an $instance, you may not use the Class::method() or Class::property options for $method argument.
  * @return bool
  *
  */
 public static function isHooked($method, Wire $instance = null)
 {
     if ($instance) {
         return $instance->hasHook($method);
     }
     $hooked = false;
     if (strpos($method, ':') !== false) {
         if (array_key_exists($method, self::$hookMethodCache)) {
             $hooked = true;
         }
         // fromClass::method() or fromClass::property
     } else {
         if (in_array($method, self::$hookMethodCache)) {
             $hooked = true;
         }
         // method() or property
     }
     return $hooked;
 }
开发者ID:avatar382,项目名称:fablab_site,代码行数:40,代码来源:Wire.php

示例10: objectToString

 /**
  * Render an object to a string
  * 
  * @param Wire|object $value
  * @return string
  * 
  */
 protected function objectToString($value)
 {
     if ($value instanceof WireArray && !$value->count()) {
         return '';
     }
     if ($value instanceof Page) {
         return $value->get('title|name');
     }
     if ($value instanceof Pagefiles || $value instanceof Pagefile) {
         $out = $this->renderInputfieldValue($value);
     } else {
         $className = get_class($value);
         $out = (string) $value;
         if ($out === $className) {
             // just the class name probably isn't useful here, see if we can do do something else with it
             $this->renderIsUseless = true;
         }
     }
     return $out;
 }
开发者ID:Smubs,项目名称:ProcessWire,代码行数:27,代码来源:MarkupFieldtype.php

示例11: save

 /**
  * Save the template to database
  *
  * @return $this|bool Returns Template if successful, or false if not
  *
  */
 public function save()
 {
     $result = Wire::getFuel('templates')->save($this);
     return $result ? $this : false;
 }
开发者ID:gusdecool,项目名称:bunga-wire,代码行数:11,代码来源:Template.php

示例12: initVar

 /**
  * Initialize the given API var
  * 
  * @param string $name
  * @param Wire $value
  * 
  */
 protected function initVar($name, $value)
 {
     if ($this->debug) {
         Debug::timer("boot.load.{$name}");
     }
     $value->init();
     if ($this->debug) {
         Debug::saveTimer("boot.load.{$name}");
     }
 }
开发者ID:avatar382,项目名称:fablab_site,代码行数:17,代码来源:ProcessWire.php

示例13: testCanSetAndGetSignal

 public function testCanSetAndGetSignal()
 {
     $wire = new Wire('a');
     $wire->setSignal(123);
     $this->assertEquals(123, $wire->getSignal());
 }
开发者ID:ashleyhindle,项目名称:advent2015,代码行数:6,代码来源:WireTest.php

示例14: setCurrentUser

 /**
  * Sets the current users
  *
  * @param User $user
  * @return this
  *
  */
 public function setCurrentUser(User $user)
 {
     $this->currentUser = $user;
     Wire::setFuel('user', $user);
     return $this;
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:13,代码来源:Users.php

示例15: log

 /**
  * Save to pages activity log, if enabled in config
  * 
  * @param $str
  * @param Page|null Page to log
  * @return WireLog
  * 
  */
 public function log($str, Page $page)
 {
     if (!in_array('pages', $this->wire('config')->logs)) {
         return parent::___log();
     }
     if ($this->wire('process') != 'ProcessPageEdit') {
         $str .= " [From URL: " . $this->wire('input')->url() . "]";
     }
     $options = array('name' => 'pages', 'url' => $page->path);
     return parent::___log($str, $options);
 }
开发者ID:posixpascal,项目名称:TrooperCMS,代码行数:19,代码来源:Pages.php


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