X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fblazy%2Ftests%2Fmodules%2Fblazy_test%2Fsrc%2FForm%2FBlazyAdminTest.php;fp=web%2Fmodules%2Fcontrib%2Fblazy%2Ftests%2Fmodules%2Fblazy_test%2Fsrc%2FForm%2FBlazyAdminTest.php;h=633cf4d9966c2926b07ca76735fded12c62f16d6;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hp=0000000000000000000000000000000000000000;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/modules/contrib/blazy/tests/modules/blazy_test/src/Form/BlazyAdminTest.php b/web/modules/contrib/blazy/tests/modules/blazy_test/src/Form/BlazyAdminTest.php new file mode 100644 index 000000000..633cf4d99 --- /dev/null +++ b/web/modules/contrib/blazy/tests/modules/blazy_test/src/Form/BlazyAdminTest.php @@ -0,0 +1,210 @@ +blazyAdmin = $blazy_admin; + $this->manager = $manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static($container->get('blazy.admin.extended'), $container->get('blazy.manager')); + } + + /** + * Returns the blazy admin. + */ + public function blazyAdmin() { + return $this->blazyAdmin; + } + + /** + * Returns the blazy_test manager. + */ + public function manager() { + return $this->manager; + } + + /** + * Returns defined skins as registered via hook_blazy_test_skins_info(). + */ + public function getSkins() { + if (!isset($this->skinDefinition)) { + $this->skinDefinition = $this->manager->buildSkins('blazy_test', '\Drupal\blazy_test\BlazyTestSkin'); + } + + return $this->skinDefinition; + } + + /** + * Returns all settings form elements. + */ + public function buildSettingsForm(array &$form, $definition = []) { + $definition += [ + 'namespace' => 'blazy', + 'optionsets' => [], + 'skins' => $this->getSkinOptions(), + 'grid_form' => TRUE, + 'style' => TRUE, + ]; + + foreach (['background', 'caches', 'fieldable_form', 'id', 'vanilla'] as $key) { + $definition[$key] = TRUE; + } + + $definition['layouts'] = isset($definition['layouts']) ? array_merge($this->getLayoutOptions(), $definition['layouts']) : $this->getLayoutOptions(); + + $this->openingForm($form, $definition); + $this->mainForm($form, $definition); + $this->closingForm($form, $definition); + } + + /** + * Returns the opening form elements. + */ + public function openingForm(array &$form, $definition = []) { + $this->blazyAdmin->openingForm($form, $definition); + } + + /** + * Returns the main form elements. + */ + public function mainForm(array &$form, $definition = []) { + if (!empty($definition['image_style_form'])) { + $this->blazyAdmin->imageStyleForm($form, $definition); + } + + if (!empty($definition['media_switch_form'])) { + $this->blazyAdmin->mediaSwitchForm($form, $definition); + } + + if (!empty($definition['grid_form'])) { + $this->blazyAdmin->gridForm($form, $definition); + } + + if (!empty($definition['fieldable_form'])) { + $this->blazyAdmin->fieldableForm($form, $definition); + } + + if (!empty($definition['breakpoints'])) { + $this->blazyAdmin->breakpointsForm($form, $definition); + } + } + + /** + * Returns the closing form elements. + */ + public function closingForm(array &$form, $definition = []) { + $this->blazyAdmin->closingForm($form, $definition); + } + + /** + * Returns available blazy_test skins for select options. + */ + public function getSkinOptions() { + if (!isset($this->skinOptions)) { + $this->skinOptions = []; + foreach ($this->getSkins() as $skin => $properties) { + $this->skinOptions[$skin] = Html::escape($properties['name']); + } + } + + return $this->skinOptions; + } + + /** + * Returns default layout options for the core Image, or Views. + */ + public function getLayoutOptions() { + return [ + 'bottom' => $this->t('Caption bottom'), + 'center' => $this->t('Caption center'), + 'top' => $this->t('Caption top'), + ]; + } + + /** + * Return the field formatter settings summary. + * + * @deprecated: Removed for self::getSettingsSummary(). + */ + public function settingsSummary($plugin, $definition = []) { + return $this->blazyAdmin->settingsSummary($plugin, $definition); + } + + /** + * Return the field formatter settings summary. + * + * @todo: Remove second param $plugin for post-release for Blazy RC2+. + */ + public function getSettingsSummary(array $definition = [], $plugin = NULL) { + // @todo: Remove condition for Blazy RC2+. + if (!method_exists($this->blazyAdmin, 'getSettingsSummary')) { + return $this->blazyAdmin->settingsSummary($plugin, $definition); + } + + return $this->blazyAdmin->getSettingsSummary($definition); + } + + /** + * Returns available fields for select options. + */ + public function getFieldOptions($target_bundles = [], $allowed_field_types = [], $entity_type_id = 'media', $target_type = '') { + return $this->blazyAdmin->getFieldOptions($target_bundles, $allowed_field_types, $entity_type_id, $target_type); + } + + /** + * Returns re-usable logic, styling and assets across fields and Views. + */ + public function finalizeForm(array &$form, $definition = []) { + $this->blazyAdmin->finalizeForm($form, $definition); + } + +}