php yii-base-Component类(方法)实例源码

下面列出了php yii-base-Component 类(方法)源码代码实例,从而了解它的用法。

作者:entityf    项目:yii2-util   
public function triggerComponentEvent($name, Event $event, Component $component)
 {
     if ($component === null) {
         return;
     }
     $component->trigger($name, $event);
 }

作者:Liv102    项目:cm   
/**
  * @param Component $component
  * @return \skeeks\sx\validate\Result
  */
 public function validate($component)
 {
     if (!$component instanceof ActiveRecord) {
         return $this->_bad(\Yii::t('app', "Object: {class} must be inherited from: {parent}", ['class' => $component->className(), 'parent' => ActiveRecord::className()]));
     }
     return !$component->isNewRecord ? $this->_ok() : $this->_bad(\Yii::t('app', "The object must already be saved"));
 }

作者:romi4    项目:yii2-seo-behavio   
/**
  * Getting behavior object from given model
  *
  * @param Component $model
  * @return SeoBehavior
  * @throws InvalidConfigException if model don't have our SeoBehavior
  */
 protected static function behavior(Component $model)
 {
     foreach ($model->getBehaviors() as $b) {
         if ($b instanceof SeoBehavior) {
             return $b;
         }
     }
     throw new InvalidConfigException('Model ' . $model->className() . ' must have SeoBehavior');
 }

作者:omniligh    项目:yz2-admi   
protected function attachSupportBehaviors(Component $owner)
 {
     $rangeAttributes = [];
     foreach ($this->attributes as $attribute => $dbAttribute) {
         $rangeAttributes[] = $attribute . '_start';
         $rangeAttributes[] = $attribute . '_end';
         $owner->attachBehavior(0, ['class' => DateTimeRangeBehavior::class, 'startAttribute' => $attribute . '_start_local', 'endAttribute' => $attribute . '_end_local', 'targetAttribute' => $attribute . '_range']);
     }
     $owner->attachBehavior(0, ['class' => DateTimeBehavior::class, 'originalFormat' => ['date', 'yyyy-MM-dd'], 'targetFormat' => ['date', 'dd.MM.yyyy'], 'attributes' => $rangeAttributes]);
 }

作者:yiico    项目:yii2-mailqueu   
public function init()
 {
     parent::init();
     //Merge main extension config with local extension config
     $config = (include dirname(__FILE__) . '/config/main.php');
     foreach ($config as $key => $value) {
         if (is_array($value)) {
             $this->{$key} = ArrayHelper::merge($value, $this->{$key});
         } elseif (null === $this->{$key}) {
             $this->{$key} = $value;
         }
     }
     if (Yii::$app instanceof Application) {
         //Merge commands map
         Yii::$app->controllerMap = ArrayHelper::merge($this->commandMap, Yii::$app->controllerMap);
         Yii::$app->controllerMap = array_filter(Yii::$app->controllerMap);
     }
     Yii::$app->setComponents($this->components);
     //Set components
     if (count($this->components)) {
         $exists = Yii::$app->getComponents(false);
         foreach ($this->components as $component => $params) {
             if (isset($exists[$component]) && is_object($exists[$component])) {
                 unset($this->components[$component]);
             } elseif (isset($exists[$component])) {
                 $this->components[$component] = ArrayHelper::merge($params, $exists[$component]);
             }
         }
         Yii::$app->setComponents($this->components, false);
     }
     Yii::setAlias('@yiicod', realpath(dirname(__FILE__) . '/..'));
 }

作者:nagse    项目:bas   
public function init()
 {
     parent::init();
     if (!$this->executePath) {
         $this->executePath = \Yii::getAlias('@app');
     }
 }

作者:shershenn    项目:yii2-se   
public function init()
 {
     parent::init();
     if (Yii::$app->view !== null) {
         Yii::$app->view->on(yii\web\View::EVENT_BEGIN_PAGE, [$this, 'eventSetMeta']);
     }
 }

作者:didwjdgk    项目:yii2-kepc   
public function init()
 {
     parent::init();
     $this->module = \kepco\Module::getInstance();
     $this->client = new \GuzzleHttp\Client(['base_uri' => 'http://srm.kepco.net/', 'cookies' => true, 'allow_redirects' => false, 'headers' => ['User-Agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36', 'Cookie' => $this->cookie, 'X-CSRF-TOKEN' => $this->token]]);
     $this->sub = \Yii::createObject(['class' => \kepco\Redis::className(), 'hostname' => $this->module->redis_server]);
 }

作者:HEXA-U    项目:supervisor-manage   
/**
  * Connection constructor.
  *
  * @param XmlRpcClient $client
  * @param array        $config
  */
 public function __construct(XmlRpcClient $client, array $config = [])
 {
     parent::__construct($config);
     $this->_connection = $client;
     $this->_initConnection();
     $this->checkConnection();
 }

作者:rafalko    项目:yii2-setting   
/**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!empty($this->preLoad)) {
         $this->load($this->preLoad);
     }
 }

作者:andreosof    项目:andreocm   
public function init()
 {
     parent::init();
     if ($this->storeInSession) {
         $this->loadFromSession();
     }
 }

作者:albertborso    项目:yii2-clickatel   
public function init()
 {
     parent::init();
     $this->_api = new \Clickatell\Api\ClickatellHttp($this->username, $this->password, $this->apiID);
     $this->_api->secure($this->secure);
     $this->setExtraParameters();
 }

作者:hhy586    项目:yii2-ticke   
/**
  * Initializes the application component.
  */
 public function init()
 {
     parent::init();
     if ($this->identityClass === null) {
         throw new InvalidConfigException('User::identityClass must be set.');
     }
 }

作者:yiimediafil    项目:mediafil   
/**
  * Init
  */
 public function init()
 {
     if ($this->path === null) {
         $this->setPath();
     }
     parent::init();
 }

作者:iw-reloa    项目:i   
public function init()
 {
     parent::init();
     if (!$this->time instanceof \DateTime) {
         throw new \yii\base\InvalidConfigException('AbstractTask::$time must be an instance of \\DateTime.');
     }
 }

作者:noorafre    项目:makmaka   
/**
  * Initializes this component.
  */
 public function init()
 {
     parent::init();
     if ($this->sourceLanguage === null) {
         $this->sourceLanguage = Yii::$app->sourceLanguage;
     }
 }

作者:phtama    项目:yii2-imageprocesso   
public function init()
 {
     parent::init();
     if (!isset($this->imagine)) {
         $this->imagine = $this->createImagine();
     }
 }

作者:pombredann    项目:xunsearc   
/**
  * Initializes the object
  */
 public function init()
 {
     parent::init();
     if (substr($this->iniDirectory, 0, 1) === '@') {
         $this->iniDirectory = Yii::getAlias($this->iniDirectory);
     }
 }

作者:didwjdgk    项目:yii2-ebid-l   
public function init()
 {
     parent::init();
     $this->module = \ebidlh\Module::getInstance();
     $this->pub = \Yii::createObject(['class' => \ebidlh\Redis::className(), 'hostname' => $this->module->redis_server]);
     $this->sub = \Yii::createObject(['class' => \ebidlh\Redis::className(), 'hostname' => $this->module->redis_server]);
 }

作者:sersi    项目:yii2-user-profil   
/**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (Yii::$app->user->isGuest) {
         throw new ErrorException('is guest');
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号