/** * Returns chat id if the type of calling entity or it's parent is Message * * @return null|int */ public function getChatId() { if ($this->entity instanceof Message) { return $this->entity->getChatId(); } $parent = $this->entity->getParent(); if ($parent instanceof Message) { return $parent->getChatId(); } return null; }
/** * @param AbstractEntity $object */ public function setUpdateType($object) { $this->updateType = static::ENTITY_TYPE; if ($object instanceof AbstractEntity) { $this->updateType = $object->getEntityType(); } }
public function __construct(array $data) { if (empty($data)) { return; } $this->setEntities($data); parent::__construct($data); }
public function __construct(array $data = []) { parent::__construct($data); $this->parseSource(); }
/** * Returns mapped event class from the configuration (if it was previously defined) * * @param AbstractEntity $entity Entity for which the corresponding event should be triggered * be treated as a command * @return null|string */ protected function getEventClass(AbstractEntity $entity) { $preDefinedEvents = $this->config->getEvents(); $entityEventType = $entity->getEntityType(); if (!is_array($preDefinedEvents)) { return null; } foreach ($preDefinedEvents as $preDefinedEvent) { if ($preDefinedEvent['type'] == $entityEventType) { $className = $preDefinedEvent['class']; if ($entity instanceof MessageEntity && $entity->isCommand()) { if (!$this->isCommandSupported($preDefinedEvent, $entity->getCommand())) { continue; } } if (class_exists($className)) { return $className; } } } return null; }
public function __construct(array $data) { $data = isset($data['message']) ? $data['message'] : $data; parent::__construct($data); }