本文整理汇总了PHP中yii\base\Component类的典型用法代码示例。如果您正苦于以下问题:PHP Component类的具体用法?PHP Component怎么用?PHP Component使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: triggerComponentEvent
public function triggerComponentEvent($name, Event $event, Component $component)
{
if ($component === null) {
return;
}
$component->trigger($name, $event);
}
示例2: validate
/**
* @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"));
}
示例3: behavior
/**
* 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');
}
示例4: attachSupportBehaviors
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]);
}
示例5: init
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__) . '/..'));
}
示例6: init
public function init()
{
parent::init();
if (!$this->executePath) {
$this->executePath = \Yii::getAlias('@app');
}
}
示例7: init
public function init()
{
parent::init();
if (Yii::$app->view !== null) {
Yii::$app->view->on(yii\web\View::EVENT_BEGIN_PAGE, [$this, 'eventSetMeta']);
}
}
示例8: init
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]);
}
示例9: __construct
/**
* 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();
}
示例10: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!empty($this->preLoad)) {
$this->load($this->preLoad);
}
}
示例11: init
public function init()
{
parent::init();
if ($this->storeInSession) {
$this->loadFromSession();
}
}
示例12: init
public function init()
{
parent::init();
$this->_api = new \Clickatell\Api\ClickatellHttp($this->username, $this->password, $this->apiID);
$this->_api->secure($this->secure);
$this->setExtraParameters();
}
示例13: init
/**
* Initializes the application component.
*/
public function init()
{
parent::init();
if ($this->identityClass === null) {
throw new InvalidConfigException('User::identityClass must be set.');
}
}
示例14: init
/**
* Init
*/
public function init()
{
if ($this->path === null) {
$this->setPath();
}
parent::init();
}
示例15: init
public function init()
{
parent::init();
if (!$this->time instanceof \DateTime) {
throw new \yii\base\InvalidConfigException('AbstractTask::$time must be an instance of \\DateTime.');
}
}