Created
February 4, 2017 19:28
-
-
Save VictorFursa/154cbf7ba64a2376d4fd3779a9fc03a5 to your computer and use it in GitHub Desktop.
event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace common\service; | |
use yii\base\Component; | |
class RequestCrawlerService extends Component | |
{ | |
const EVENT_INFO_AFTER_SAVE = 'infoAfterSave'; | |
/** @var object $serializer */ | |
public $serializer; | |
/** @var string $pathToSave */ | |
public $pathToSave; | |
/** | |
* RequestCrawlerService constructor. | |
* @param SerializerInterface $serializer | |
* @param array $config | |
*/ | |
public function __construct(SerializerInterface $serializer, $config = []) | |
{ | |
$this->serializer = $serializer; | |
// можно так $this->on(self::EVENT_INFO_AFTER_SAVE, [Test::className(), 'info']); | |
parent::__construct($config); | |
} | |
/** | |
* @param $encoded | |
*/ | |
public function encodedAndSaveFile($encoded) | |
{ | |
file_put_contents($this->pathToSave . '/' . time() . '.txt', $encoded, FILE_APPEND | LOCK_EX); | |
$this->trigger(self::EVENT_INFO_AFTER_SAVE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment