Queue all URLs

@param  Varien_Object $eventObject
@return null
322016
public function queueAllUrls($eventObject) {
        $helper = Mage::helper('turpentine/cron');
        if ($helper->getCrawlerEnabled()) {
            $helper->addUrlsToCrawlerQueue($helper->getAllUrls());
        }
    }
1219559
public function setEventQueueFactory(EventQueueFactoryInterface $queueFactory)
    {
        parent::setEventQueueFactory($queueFactory);
        foreach ($this->plugins as $plugin) {
            if (!($plugin instanceof EventQueueFactoryAwareInterface)) {
                continue;
            }

            $plugin->setEventQueueFactory($queueFactory);
        }
    }
1208528
private function selectSequenceFlow(TransitionalInterface $currentFlowObject)
    {
        foreach ($this->connectingObjectCollection->filterBySource($currentFlowObject) as $connectingObject) { /* @var $connectingObject ConnectingObjectInterface */
            if ($connectingObject instanceof SequenceFlow) {
                if (!($currentFlowObject instanceof ConditionalInterface) || $connectingObject->getId() !== $currentFlowObject->getDefaultSequenceFlowId()) {
                    $condition = $connectingObject->getCondition();
                    if ($condition === null) {
                        $selectedSequenceFlow = $connectingObject;
                        break;
                    } else {
                        $expressionLanguage = $this->expressionLanguage ?: new ExpressionLanguage();
                        if ($expressionLanguage->evaluate($condition, $this->processData)) {
                            $selectedSequenceFlow = $connectingObject;
                            break;
                        }
                    }
                }
            }
        }

        if (!isset($selectedSequenceFlow)) {
            if (!($currentFlowObject instanceof ConditionalInterface) || $currentFlowObject->getDefaultSequenceFlowId() === null) {
                throw new SequenceFlowNotSelectedException(sprintf('No sequence flow can be selected on "%s".', $currentFlowObject->getId()));
            }

            $selectedSequenceFlow = $this->connectingObjectCollection->get($currentFlowObject->getDefaultSequenceFlowId());
        }

        $this->stateMachine->triggerEvent($selectedSequenceFlow->getDestination()->getId());

        if ($this->getCurrentFlowObject() instanceof GatewayInterface) {
            $gateway = $this->getCurrentFlowObject();
            $this->selectSequenceFlow(/* @var $gateway GatewayInterface */$gateway);
        }
    }
289326
public function writeTopLevelElement(QueryResult $entryObject)
    {
        if (!isset($entryObject->results)) {
            array_pop($this->lightStack);
            return null;
        }
        if (!$entryObject->results instanceof Model) {
            $res = $entryObject->results;
            $msg = is_array($res) ? 'Entry object must be single Model' : get_class($res);
            throw new InvalidOperationException($msg);
        }

        $this->loadStackIfEmpty();
        $baseURI = $this->isBaseWritten ? null : $this->absoluteServiceUriWithSlash;
        $this->isBaseWritten = true;

        $stackCount = count($this->lightStack);
        $topOfStack = $this->lightStack[$stackCount-1];
        $payloadClass = get_class($entryObject->results);
        $resourceType = $this->getService()->getProvidersWrapper()->resolveResourceType($topOfStack['type']);

        // need gubbinz to unpack an abstract resource type
        $resourceType = $this->getConcreteTypeFromAbstractType($resourceType, $payloadClass);

        // make sure we're barking up right tree
        if (!$resourceType instanceof ResourceEntityType) {
            throw new InvalidOperationException(get_class($resourceType));
        }
        $targClass = $resourceType->getInstanceType()->getName();
        if (!($entryObject->results instanceof $targClass)) {
            $msg = 'Object being serialised not instance of expected class, '
                   . $targClass . ', is actually ' . $payloadClass;
            throw new InvalidOperationException($msg);
        }

        if (!array_key_exists($targClass, $this->propertiesCache)) {
            $rawProp = $resourceType->getAllProperties();
            $relProp = [];
            $nonRelProp = [];
            foreach ($rawProp as $prop) {
                $propType = $prop->getResourceType();
                if ($propType instanceof ResourceEntityType) {
                    $relProp[] = $prop;
                } else {
                    $nonRelProp[$prop->getName()] = ['prop' => $prop, 'type' => $propType->getInstanceType()];
                }
            }
            $this->propertiesCache[$targClass] = ['rel' => $relProp, 'nonRel' => $nonRelProp];
        }
        unset($relProp);
        unset($nonRelProp);
        $relProp = $this->propertiesCache[$targClass]['rel'];
        $nonRelProp = $this->propertiesCache[$targClass]['nonRel'];

        $resourceSet = $resourceType->getCustomState();
        if (!$resourceSet instanceof ResourceSet) {
            throw new InvalidOperationException('');
        }
        $title = $resourceType->getName();
        $type = $resourceType->getFullName();

        $relativeUri = $this->getEntryInstanceKey(
            $entryObject->results,
            $resourceType,
            $resourceSet->getName()
        );
        $absoluteUri = rtrim($this->absoluteServiceUri, '/') . '/' . $relativeUri;

        list($mediaLink, $mediaLinks) = $this->writeMediaData(
            $entryObject->results,
            $type,
            $relativeUri,
            $resourceType
        );

        $propertyContent = $this->writePrimitiveProperties($entryObject->results, $nonRelProp);

        $links = [];
        foreach ($relProp as $prop) {
            $nuLink = new ODataLink();
            $propKind = $prop->getKind();

            if (!(ResourcePropertyKind::RESOURCESET_REFERENCE == $propKind
                  || ResourcePropertyKind::RESOURCE_REFERENCE == $propKind)) {
                $msg = '$propKind != ResourcePropertyKind::RESOURCESET_REFERENCE &&'
                       .' $propKind != ResourcePropertyKind::RESOURCE_REFERENCE';
                throw new InvalidOperationException($msg);
            }
            $propTail = ResourcePropertyKind::RESOURCE_REFERENCE == $propKind ? 'entry' : 'feed';
            $propType = 'application/atom+xml;type=' . $propTail;
            $propName = $prop->getName();
            $nuLink->title = $propName;
            $nuLink->name = ODataConstants::ODATA_RELATED_NAMESPACE . $propName;
            $nuLink->url = $relativeUri . '/' . $propName;
            $nuLink->type = $propType;
            $nuLink->isExpanded = false;
            $nuLink->isCollection = 'feed' === $propTail;

            $shouldExpand = $this->shouldExpandSegment($propName);

            $navProp = new ODataNavigationPropertyInfo($prop, $shouldExpand);
            if ($navProp->expanded) {
                $this->expandNavigationProperty($entryObject, $prop, $nuLink, $propKind, $propName);
            }
            $nuLink->isExpanded = isset($nuLink->expandedResult);
            if (null === $nuLink->isCollection) {
                throw new InvalidOperationException('');
            }

            $links[] = $nuLink;
        }

        $odata = new ODataEntry();
        $odata->resourceSetName = $resourceSet->getName();
        $odata->id = $absoluteUri;
        $odata->title = new ODataTitle($title);
        $odata->type = new ODataCategory($type);
        $odata->propertyContent = $propertyContent;
        $odata->isMediaLinkEntry = $resourceType->isMediaLinkEntry();
        $odata->editLink = new ODataLink();
        $odata->editLink->url = $relativeUri;
        $odata->editLink->name = 'edit';
        $odata->editLink->title = $title;
        $odata->mediaLink = $mediaLink;
        $odata->mediaLinks = $mediaLinks;
        $odata->links = $links;
        $odata->updated = $this->getUpdated()->format(DATE_ATOM);
        $odata->baseURI = $baseURI;

        $newCount = count($this->lightStack);
        if ($newCount != $stackCount) {
            $msg = 'Should have ' . $stackCount . ' elements in stack, have ' . $newCount . ' elements';
            throw new InvalidOperationException($msg);
        }
        $this->lightStack[$newCount-1]['count']--;
        if (0 == $this->lightStack[$newCount-1]['count']) {
            array_pop($this->lightStack);
        }
        return $odata;
    }
654521
public function dequeue(AnObjectHandlable $object)
    {
        $this->getRepositoryEntities($object->getRepository())->extract($object);

        return parent::dequeue($object);
    }
313777
public function setCustomerGroupCookie($eventObject) {
        $customer = $eventObject->getCustomer();
        $cookie = Mage::getSingleton('core/cookie');
        if (Mage::getStoreConfig('persistent/options/enabled')) {
            $cookie->set('customer_group', $customer->getGroupId(), Mage::getStoreConfig('persistent/options/lifetime'));
        } else {
            $cookie->set('customer_group', $customer->getGroupId());
        }
    }
1323248
public function banProductReview($eventObject) {
        if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) {
            $patterns = array();
            /* @var $review \Mage_Review_Model_Review*/
            $review = $eventObject->getObject();

            /* @var $productCollection \Mage_Review_Model_Resource_Review_Product_Collection*/
            $productCollection = $review->getProductCollection();

            $products = $productCollection->addEntityFilter((int) $review->getEntityPkValue())->getItems();

            $productIds = array_unique(array_map(
                create_function('$p', 'return $p->getEntityId();'),
                $products ));
            $patterns[] = sprintf('/review/product/list/id/(?:%s)/category/',
                implode('|', array_unique($productIds)));
            $patterns[] = sprintf('/review/product/view/id/%d/',
                $review->getEntityId());
            $productPatterns = array();
            foreach ($products as $p) {
                $urlKey = $p->getUrlModel()->formatUrlKey($p->getName());
                if ($urlKey) {
                    $productPatterns[] = $urlKey;
                }
            }
            if ( ! empty($productPatterns)) {
                $productPatterns = array_unique($productPatterns);
                $patterns[] = sprintf('(?:%s)', implode('|', $productPatterns));
            }
            $urlPattern = implode('|', $patterns);

            $result = $this->_getVarnishAdmin()->flushUrl($urlPattern);
            return $this->_checkResult($result);
        }
    }
695384
public function rollbackUrl($object)
    {
        $class = str_replace('\\', '_', get_class($object));

        return url($this->backendRoute.'/rollback/'.$class.'/'.$object->id);
    }
713695
public function readEventBatch(array $eventUrls): array
    {
        $requests = array_map(
            function ($eventUrl) {
                return $this->getJsonRequest($eventUrl);
            },
            $eventUrls
        );

        $responses = $this->httpClient->sendRequestBatch($requests);

        return array_map(
            function ($response) {
                $data = json_decode($response->getBody(), true);
                if (!isset($data['content'])) {
                    return null;
                }

                return $this->createEventFromResponseContent(
                    $data['content']
                );
            },
            $responses
        );
    }
1228660
public function pong(EventInterface $event, EventQueueInterface $queue)
    {
        $params = $event->getParams();
        $queue->ircPong($params['server1']);
    }
439710
public function watchForRead($socketObject) : void
    {
        $rawSocket = $this->getRawSocket($socketObject);
        \array_push($this->watchedSockets, $rawSocket);
        $this->watchedSocketObjects[$this->getRawSocketKey($rawSocket)] = $socketObject;
    }
1080807
public function setCallbackObject($callbackObject = FALSE)
    {
        $this->callbackObject = $callbackObject;
        $this->debug->debug(__FUNCTION__, 'setCallbackObject: ' . json_encode($this->callbackObject));
    }
232739
public function send(EventInterface $event) {
        $request = $event->getRequest();
        $response = $event->getResponse();

        // Vary on public key header. Public key specified in query and URL path doesn't have to be
        // taken into consideration, since they will have varying URLs
        $response->setVary('X-Imbo-PublicKey', false);

        // Optionally mark this response as not modified
        $response->isNotModified($request);

        // Inject a possible image identifier into the response headers
        $imageIdentifier = null;

        if ($image = $request->getImage()) {
            // The request has an image. This means that an image was just added.
            // Get the image identifier from the image model
            $imageIdentifier = $image->getImageIdentifier();
        } else if ($identifier = $request->getImageIdentifier()) {
            // An image identifier exists in the request URI, use that
            $imageIdentifier = $identifier;
        }

        if ($imageIdentifier) {
            $response->headers->set('X-Imbo-ImageIdentifier', $imageIdentifier);
        }

        $response->send();
    }
453166
protected function getListeners(Event $eventObject) {
        $listeners = $this->getOption(self::OPTION_LISTENERS);
        return isset($listeners[$eventObject->getName()])
            ? $listeners[$eventObject->getName()]
            : array();
    }
219514
public function banProductPageCache($eventObject) {
        if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) {
            $banHelper = Mage::helper('turpentine/ban');
            $product = $eventObject->getProduct();
            $urlPattern = $banHelper->getProductBanRegex($product);
            $result = $this->_getVarnishAdmin()->flushUrl($urlPattern);
            Mage::dispatchEvent('turpentine_ban_product_cache', $result);
            $cronHelper = Mage::helper('turpentine/cron');
            if ($this->_checkResult($result) &&
                    $cronHelper->getCrawlerEnabled()) {
                $cronHelper->addProductToCrawlerQueue($product);
                foreach ($banHelper->getParentProducts($product)
                        as $parentProduct) {
                    $cronHelper->addProductToCrawlerQueue($parentProduct);
                }
            }
        }
    }
1175095
public function getListenerQueue($event)
    {
        if ($event instanceof EventInterface) {
            $event = $event->getName();
        }

        if (isset($this->listeners[$event])) {
            return $this->listeners[$event];
        }

        return null;
    }
835573
public function dispatch($event, Event $eventObject)
    {
        if (!isset($this->listeners[$event])) {
            return;
        }
        
        foreach ($this->listeners[$event] as $listener) {
            call_user_func_array($listener, array($eventObject));
            
            if ($eventObject->propagationHalted()) {
                break;
            }
        }
    }