/** * {@inheritDoc} */ public function populate(EnvironmentInterface $environment) { if (!$environment->getInputProvider()) { $environment->setInputProvider(new InputProvider()); } if (!$environment->getClipboard()) { $environment->setClipboard(new DefaultClipboard()); } $this->populateController($environment); }
/** * Calculate all clipboard items for the current view. * * @return ItemInterface[] */ private function calculateClipboardItems() { $dataDefinition = $this->environment->getDataDefinition(); $basicDefinition = $dataDefinition->getBasicDefinition(); $clipboard = $this->environment->getClipboard(); $filter = new Filter(); $filter->andModelIsFromProvider($basicDefinition->getDataProvider()); if ($parentDataProviderName = $basicDefinition->getParentDataProvider()) { $filter->andParentIsFromProvider($parentDataProviderName); } else { $filter->andHasNoParent(); } return $clipboard->fetch($filter); }
/** * {@inheritDoc} */ public function populate(EnvironmentInterface $environment) { if (!$environment->getSessionStorage()) { $environment->setSessionStorage(new SessionStorage('DC_GENERAL_' . strtoupper($environment->getDataDefinition()->getName()))); } if (!$environment->getInputProvider()) { $environment->setInputProvider(new InputProvider()); } if (!$environment->getClipboard()) { $environment->setClipboard(new Clipboard()); } if (!$environment->getBaseConfigRegistry()) { $baseConfigRegistry = new BaseConfigRegistry(); $baseConfigRegistry->setEnvironment($environment); $environment->setBaseConfigRegistry($baseConfigRegistry); } $this->populateController($environment); }
/** * Handle the paste into and after buttons. * * @param GetPasteButtonEvent $event The event. * * @return void * * @throws \RuntimeException When more than one model is contained within the clipboard. */ public function handle(GetPasteButtonEvent $event) { $this->circularReference = $event->isCircularReference(); $this->environment = $event->getEnvironment(); $this->provider = $this->environment->getDataProvider(); $this->providerName = $this->provider->getEmptyModel()->getProviderName(); $clipboard = $this->environment->getClipboard(); $this->currentModel = $event->getModel(); $this->disablePI = true; $this->disablePA = true; // Only run for a MetaModels and if both values already disabled return here. if (substr($this->providerName, 0, 3) !== 'mm_' || $event->isPasteIntoDisabled() && $event->isPasteAfterDisabled()) { return; } $this->checkForAction($clipboard, 'copy'); $this->checkForAction($clipboard, 'create'); $this->checkForAction($clipboard, 'cut'); $event->setPasteAfterDisabled($this->disablePA)->setPasteIntoDisabled($this->disablePI); }