Skip to content

Commit

Permalink
Refactor RenderElementExtensionTest
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Jan 7, 2021
1 parent 1ef518a commit 21fbab7
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 132 deletions.
12 changes: 6 additions & 6 deletions src/Twig/Extension/RenderElementExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ public function renderRelationElement($element, FieldDescriptionInterface $field

if (null === $propertyPath) {
// For BC kept associated_tostring option behavior
// NEXT_MAJOR Remove next line.
$method = $fieldDescription->getOption('associated_tostring');

// NEXT_MAJOR: Remove the "if" part and leave the "else" part
if ($method) {
@trigger_error(
'Option "associated_tostring" is deprecated since version 2.3 and will be removed in 4.0. Use "associated_property" instead.',
Expand Down Expand Up @@ -300,8 +301,9 @@ public function renderRelationElement($element, FieldDescriptionInterface $field
}

/**
* NEXT_MAJOR: Make this method protected
* Get template.
* NEXT_MAJOR: Make this method private.
*
* @internal This method will be private in the next major version
*
* @param string $defaultTemplate
*
Expand Down Expand Up @@ -339,8 +341,6 @@ public function getTemplate(
}

/**
* NEXT MAJOR: Make this method private.
*
* Extracts the object and requested value from the $listElement.
*
* @param object|array $listElement
Expand All @@ -349,7 +349,7 @@ public function getTemplate(
*
* @return array An array containing object and value
*/
public function getObjectAndValueFromListElement(
private function getObjectAndValueFromListElement(
$listElement,
FieldDescriptionInterface $fieldDescription
): array {
Expand Down
30 changes: 0 additions & 30 deletions src/Twig/Extension/SonataAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,34 +754,4 @@ protected function getTemplate(

return $this->renderElementExtension->getTemplate($fieldDescription, $defaultTemplate, $$environment);
}

/**
* NEXT_MAJOR: Remove this method
* Extracts the object and requested value from the $listElement.
*
* @param object|array $listElement
*
* @throws \TypeError when $listElement is not an object or an array with an object on offset 0
*
* @return array An array containing object and value
*
* @deprecated since sonata-project/admin-bundle 3.x and will be removed in 4.0
*/
private function getObjectAndValueFromListElement(
$listElement,
FieldDescriptionInterface $fieldDescription
): array {
if ('sonata_deprecation_mute' !== (\func_get_args()[2] ?? null)) {
@trigger_error(sprintf(
'The %s method is deprecated in favor of RenderElementExtension::getObjectAndValueFromListElement since version 3.x and will be removed in 4.0.',
__METHOD__
), E_USER_DEPRECATED);
}

if (null === $this->renderElementExtension) {
$this->renderElementExtension = new RenderElementExtension($this->propertyAccessor, $this->templateRegistries, $this->logger);
}

return $this->renderElementExtension->getObjectAndValueFromListElement($listElement, $fieldDescription);
}
}
8 changes: 0 additions & 8 deletions src/Twig/Extension/XEditableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ public function getXEditableType(string $type)
return $this->xEditableTypeMapping[$type] ?? false;
}

/**
* @param string[] $xEditableTypeMapping
*/
public function setXEditableTypeMapping($xEditableTypeMapping)
{
$this->xEditableTypeMapping = $xEditableTypeMapping;
}

/**
* Return xEditable choices based on the field description choices options & catalogue options.
* With the following choice options:
Expand Down
Loading

0 comments on commit 21fbab7

Please sign in to comment.