/** * @param string $methodName * @param array $args */ public function load($entities, DcCompat $compat) { $providerName = $compat->getModel()->getProviderName(); $enviroment = $compat->getEnvironment(); /** @var EntityDataProvider $dataProvider */ $dataProvider = $enviroment->getDataProvider($providerName); $entityManager = $dataProvider->getEntityManager(); $metaFactory = $entityManager->getMetadataFactory(); $metaData = $metaFactory->getMetadataFor($dataProvider->getEntityRepository()->getClassName()); $associationNames = $metaData->getAssociationNames(); $entityAccessor = EntityHelper::getEntityAccessor(); $ids = array(); if (is_array($entities) || $entities instanceof \Traversable) { foreach ($entities as $entity) { if (is_object($entity)) { $ids[] = $entityAccessor->getPrimaryKey($entity); continue; } if (!empty($associationNames) && in_array($compat->getPropertyName(), $associationNames)) { $ids[] = $entity; } } } return $ids; }
/** * Get a list of areas from the parent category. * * @param DcCompat $dc * * @param array $options * @param CreateOptionsEvent $event * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.Superglobals) * * @return array */ public function getMessageContentCellOptions($dc, $options = array(), CreateOptionsEvent $event = null) { if ($dc instanceof DcCompat) { /** @var EntityModel $model */ $model = $dc->getModel(); /** @var \Avisota\Contao\Entity\MessageContent $content */ $content = $model->getEntity(); $message = $content->getMessage(); $layout = $message->getLayout(); if (!$layout || $layout->getType() != 'mailChimp') { return $options; } list($templateGroup, $templateName) = explode(':', $layout->getMailchimpTemplate()); $mailChimpTemplate = $GLOBALS['AVISOTA_MAILCHIMP_TEMPLATE'][$templateGroup][$templateName]; $cells = $mailChimpTemplate['cells']; $rows = isset($mailChimpTemplate['rows']) ? $mailChimpTemplate['rows'] : array(); $repeatableCells = array(); foreach ($rows as $row) { $repeatableCells = array_merge($repeatableCells, $row['affectedCells']); } foreach ($cells as $cellName => $cell) { if (!isset($cell['content'])) { if (isset($GLOBALS['TL_LANG']['orm_avisota_message_content']['cells'][$cellName])) { $label = $GLOBALS['TL_LANG']['orm_avisota_message_content']['cells'][$cellName]; } else { $label = $cellName; } $options[$cellName] = $label; } } if ($event) { $event->preventDefault(); } } else { foreach ($GLOBALS['AVISOTA_MAILCHIMP_TEMPLATE'] as $templates) { foreach ($templates as $template) { foreach ($template['cells'] as $cellName => $cell) { if (!isset($options[$cellName])) { if (isset($GLOBALS['TL_LANG']['orm_avisota_message_content']['cells'][$cellName])) { $label = $GLOBALS['TL_LANG']['orm_avisota_message_content']['cells'][$cellName]; } else { $label = $cellName; } $options[$cellName] = $label; } } } } if ($event) { $event->preventDefault(); } } return $options; }
/** * Get the model. * * @return ModelInterface */ public function getModel() { return $this->dataContainer->getModel(); }