| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /**
- * Link : http://www.phpcorner.net
- * User : qingbing<780042175@qq.com>
- * Date : 2018-12-07
- * Version : 1.0
- */
- namespace TestClass;
- use Abstracts\Base;
- use Helper\Event;
- class DemoBase extends Base
- {
- public $age;
- private $_name;
- private $_sex;
- /**
- * @return string
- */
- public function getName()
- {
- return $this->_name;
- }
- /**
- * @param string $name
- */
- public function setName($name)
- {
- $this->_name = $name;
- }
- /**
- * @return mixed
- */
- public function getSex()
- {
- return $this->_sex;
- }
- /**
- * @param mixed $sex
- */
- public function setSex($sex)
- {
- $this->_sex = $sex;
- }
- /**
- * @throws \Helper\Exception
- */
- public function login()
- {
- if ($this->hasEventHandler('beforeLogin')) {
- $this->onBeforeLogin(new Event($this));
- }
- var_dump('login');
- if ($this->hasEventHandler('afterLogin')) {
- $this->onAfterLogin(new Event($this, ['name' => 'qingbing']));
- }
- }
- /**
- * 调用及触发 beforeLogin 事件
- * @param Event $event
- * @throws \Helper\Exception
- */
- public function onBeforeLogin($event)
- {
- $this->raiseEvent('beforeLogin', $event);
- }
- /**
- * 调用及触发 afterLogin 事件
- * @param Event $event
- * @throws \Helper\Exception
- */
- public function onAfterLogin($event)
- {
- $this->raiseEvent('afterLogin', $event);
- }
- }
|