/**
* Set RabbitMQ/Redis Producer to send each entry to a queue.
* This method should be called when user has enabled RabbitMQ.
- *
- * @param ProducerInterface $producer
*/
public function setProducer(ProducerInterface $producer)
{
/**
* Set current user.
* Could the current *connected* user or one retrieve by the consumer.
- *
- * @param User $user
*/
public function setUser(User $user)
{
/**
* Parse one entry.
*
- * @param array $importedEntry
- *
* @return Entry
*/
abstract public function parseEntry(array $importedEntry);
+ /**
+ * Validate that an entry is valid (like has some required keys, etc.).
+ *
+ * @return bool
+ */
+ abstract public function validateEntry(array $importedEntry);
+
/**
* Fetch content from the ContentProxy (using graby).
* If it fails return the given entry to be saved in all case (to avoid user to loose the content).
/**
* Parse and insert all given entries.
- *
- * @param $entries
*/
- protected function parseEntries($entries)
+ protected function parseEntries(array $entries)
{
$i = 1;
$entryToBeFlushed = [];
$importedEntry = $this->setEntryAsRead($importedEntry);
}
+ if (false === $this->validateEntry($importedEntry)) {
+ continue;
+ }
+
$entry = $this->parseEntry($importedEntry);
if (null === $entry) {
*
* Faster parse entries for Producer.
* We don't care to make check at this time. They'll be done by the consumer.
- *
- * @param array $entries
*/
protected function parseEntriesForProducer(array $entries)
{
* Set current imported entry to archived / read.
* Implementation is different accross all imports.
*
- * @param array $importedEntry
- *
* @return array
*/
abstract protected function setEntryAsRead(array $importedEntry);