Loading uc_attribute/uc_attribute.links.task.yml +4 −4 Changes for uc_attribute/uc_attribute.links.task.yml: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -17,10 +17,10 @@ uc_attribute.product_adjustments: uc_attribute.product_class_attributes: route_name: uc_attribute.product_class_attributes base_route: entity.node_type.edit_form title: Attributes weight: 1 title: Product attributes weight: 4 uc_attribute.product_class_options: route_name: uc_attribute.product_class_options base_route: entity.node_type.edit_form title: Options weight: 2 title: Product options weight: 5 uc_attribute/uc_attribute.routing.yml +3 Changes for uc_attribute/uc_attribute.routing.yml: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ uc_attribute.product_class_attributes: _form: '\Drupal\uc_attribute\Form\ProductClassAttributesForm' _title: 'Attributes' requirements: _uc_product_node_type: 'TRUE' _entity_access: 'node_type.update' _permission: 'administer attributes' Loading @@ -77,6 +78,7 @@ uc_attribute.product_class_attributes_add: _form: '\Drupal\uc_attribute\Form\ProductClassAttributesAddForm' _title: 'Add attribute' requirements: _uc_product_node_type: 'TRUE' _entity_access: 'node_type.update' _permission: 'administer attributes' Loading @@ -86,6 +88,7 @@ uc_attribute.product_class_options: _form: '\Drupal\uc_attribute\Form\ProductClassOptionsForm' _title: 'Options' requirements: _uc_product_node_type: 'TRUE' _entity_access: 'node_type.update' _permission: 'administer attributes' Loading uc_product/src/Access/ProductTypeAccessCheck.php +26 Changes for uc_product/src/Access/ProductTypeAccessCheck.php: 26 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\uc_product\Access\ProductTypeAccessCheck. */ namespace Drupal\uc_product\Access; use Drupal\Core\Access\AccessResult; use Drupal\Core\Routing\Access\AccessInterface; use Drupal\node\NodeTypeInterface; /** * Provides an access checker for product-type nodes. */ class ProductTypeAccessCheck implements AccessInterface { /** * {@inheritdoc} */ public function access(NodeTypeInterface $node_type) { return AccessResult::allowedIf($node_type->getThirdPartySetting('uc_product', 'product', FALSE)); } } uc_product/src/Tests/ProductTabsTest.php +24 Changes for uc_product/src/Tests/ProductTabsTest.php: 24 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ class ProductTabsTest extends UbercartTestBase { public static $modules = array('uc_product', 'uc_attribute', 'uc_stock'); public static $adminPermissions = array( 'bypass node access', 'administer attributes', 'administer product attributes', 'administer product options', 'administer product stock', Loading Loading @@ -65,4 +66,27 @@ class ProductTabsTest extends UbercartTestBase { $this->assertNoLink('Stock'); } public function testProductTypeTabs() { $this->drupalGet('admin/structure/types/manage/product'); // Check we are on the node type page. $this->assertFieldByName('name', 'Product'); // Check that each of the tabs exist. $this->assertLink('Product attributes'); $this->assertLink('Product options'); } public function testNonProductTypeTabs() { $type = $this->drupalCreateContentType(['type' => 'page']); $this->drupalGet('admin/structure/types/manage/' . $type->id()); // Check we are on the node type page. $this->assertFieldByName('name', $type->label()); // Check that each of the tabs do not exist. $this->assertNoLink('Product attributes'); $this->assertNoLink('Product options'); } } uc_product/uc_product.services.yml +4 Changes for uc_product/uc_product.services.yml: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,3 +3,7 @@ services: class: Drupal\uc_product\Access\ProductAccessCheck tags: - { name: access_check, applies_to: _uc_product_is_product } access_check.uc_product_node_type: class: Drupal\uc_product\Access\ProductTypeAccessCheck tags: - { name: access_check, applies_to: _uc_product_node_type } Loading
uc_attribute/uc_attribute.links.task.yml +4 −4 Changes for uc_attribute/uc_attribute.links.task.yml: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -17,10 +17,10 @@ uc_attribute.product_adjustments: uc_attribute.product_class_attributes: route_name: uc_attribute.product_class_attributes base_route: entity.node_type.edit_form title: Attributes weight: 1 title: Product attributes weight: 4 uc_attribute.product_class_options: route_name: uc_attribute.product_class_options base_route: entity.node_type.edit_form title: Options weight: 2 title: Product options weight: 5
uc_attribute/uc_attribute.routing.yml +3 Changes for uc_attribute/uc_attribute.routing.yml: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ uc_attribute.product_class_attributes: _form: '\Drupal\uc_attribute\Form\ProductClassAttributesForm' _title: 'Attributes' requirements: _uc_product_node_type: 'TRUE' _entity_access: 'node_type.update' _permission: 'administer attributes' Loading @@ -77,6 +78,7 @@ uc_attribute.product_class_attributes_add: _form: '\Drupal\uc_attribute\Form\ProductClassAttributesAddForm' _title: 'Add attribute' requirements: _uc_product_node_type: 'TRUE' _entity_access: 'node_type.update' _permission: 'administer attributes' Loading @@ -86,6 +88,7 @@ uc_attribute.product_class_options: _form: '\Drupal\uc_attribute\Form\ProductClassOptionsForm' _title: 'Options' requirements: _uc_product_node_type: 'TRUE' _entity_access: 'node_type.update' _permission: 'administer attributes' Loading
uc_product/src/Access/ProductTypeAccessCheck.php +26 Changes for uc_product/src/Access/ProductTypeAccessCheck.php: 26 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\uc_product\Access\ProductTypeAccessCheck. */ namespace Drupal\uc_product\Access; use Drupal\Core\Access\AccessResult; use Drupal\Core\Routing\Access\AccessInterface; use Drupal\node\NodeTypeInterface; /** * Provides an access checker for product-type nodes. */ class ProductTypeAccessCheck implements AccessInterface { /** * {@inheritdoc} */ public function access(NodeTypeInterface $node_type) { return AccessResult::allowedIf($node_type->getThirdPartySetting('uc_product', 'product', FALSE)); } }
uc_product/src/Tests/ProductTabsTest.php +24 Changes for uc_product/src/Tests/ProductTabsTest.php: 24 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ class ProductTabsTest extends UbercartTestBase { public static $modules = array('uc_product', 'uc_attribute', 'uc_stock'); public static $adminPermissions = array( 'bypass node access', 'administer attributes', 'administer product attributes', 'administer product options', 'administer product stock', Loading Loading @@ -65,4 +66,27 @@ class ProductTabsTest extends UbercartTestBase { $this->assertNoLink('Stock'); } public function testProductTypeTabs() { $this->drupalGet('admin/structure/types/manage/product'); // Check we are on the node type page. $this->assertFieldByName('name', 'Product'); // Check that each of the tabs exist. $this->assertLink('Product attributes'); $this->assertLink('Product options'); } public function testNonProductTypeTabs() { $type = $this->drupalCreateContentType(['type' => 'page']); $this->drupalGet('admin/structure/types/manage/' . $type->id()); // Check we are on the node type page. $this->assertFieldByName('name', $type->label()); // Check that each of the tabs do not exist. $this->assertNoLink('Product attributes'); $this->assertNoLink('Product options'); } }
uc_product/uc_product.services.yml +4 Changes for uc_product/uc_product.services.yml: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,3 +3,7 @@ services: class: Drupal\uc_product\Access\ProductAccessCheck tags: - { name: access_check, applies_to: _uc_product_is_product } access_check.uc_product_node_type: class: Drupal\uc_product\Access\ProductTypeAccessCheck tags: - { name: access_check, applies_to: _uc_product_node_type }