-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
334 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Templating; | ||
|
||
abstract class AbstractTemplateRegistry implements TemplateRegistryInterface | ||
{ | ||
/** | ||
* @var array<string, string> | ||
*/ | ||
protected $templates = []; | ||
|
||
/** | ||
* @param string[] $templates | ||
*/ | ||
public function __construct(array $templates = []) | ||
{ | ||
$this->templates = $templates; | ||
} | ||
|
||
public function getTemplates(): array | ||
{ | ||
return $this->templates; | ||
} | ||
|
||
public function hasTemplate(string $name): bool | ||
{ | ||
return isset($this->templates[$name]); | ||
} | ||
|
||
/** | ||
* NEXT_MAJOR: add type hint. | ||
* | ||
* @param string $name | ||
*/ | ||
public function getTemplate($name): ?string | ||
{ | ||
if ($this->hasTemplate($name)) { | ||
return $this->templates[$name]; | ||
} | ||
|
||
@trigger_error(sprintf( | ||
'Passing a nonexistent template name as argument 1 to %s() is deprecated since' | ||
.' sonata-project/admin-bundle 3.52 and will throw an exception in 4.0.', | ||
__METHOD__ | ||
), E_USER_DEPRECATED); | ||
|
||
// NEXT_MAJOR : remove the previous `trigger_error()` call, the `return null` statement, uncomment the following exception and declare string as return type | ||
// throw new \InvalidArgumentException(sprintf( | ||
// 'Template named "%s" doesn\'t exist.', | ||
// $name | ||
// )); | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Templating; | ||
|
||
/** | ||
* @author Wojciech Błoszyk <[email protected]> | ||
*/ | ||
final class MutableTemplateRegistry extends AbstractTemplateRegistry implements MutableTemplateRegistryInterface | ||
{ | ||
// NEXT_MAJOR: change method declaration for new one | ||
// public function setTemplates(array $templates): void | ||
public function setTemplates(array $templates) | ||
{ | ||
$this->templates = $templates; | ||
} | ||
|
||
// NEXT_MAJOR: change method declaration for new one | ||
// public function setTemplate(string $name, string $template): void | ||
public function setTemplate($name, $template) | ||
{ | ||
$this->templates[$name] = $template; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Templating; | ||
|
||
/** | ||
* @author Wojciech Błoszyk <[email protected]> | ||
* | ||
* @method MutableTemplateRegistryInterface getTemplateRegistry() | ||
* @method bool hasTemplateRegistry() | ||
* @method void setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry) | ||
*/ | ||
interface MutableTemplateRegistryAwareInterface | ||
{ | ||
// NEXT_MAJOR: uncomment this method in 4.0 | ||
//public function getTemplateRegistry(): MutableTemplateRegistryInterface; | ||
|
||
// NEXT_MAJOR: uncomment this method in 4.0 | ||
//public function setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,109 +15,38 @@ | |
|
||
/** | ||
* @author Timo Bakx <[email protected]> | ||
* | ||
* NEXT_MAJOR: remove `MutableTemplateRegistryInterface` implementation. | ||
*/ | ||
final class TemplateRegistry implements MutableTemplateRegistryInterface | ||
final class TemplateRegistry extends AbstractTemplateRegistry implements MutableTemplateRegistryInterface | ||
{ | ||
public const TYPE_ARRAY = 'array'; | ||
public const TYPE_BOOLEAN = 'boolean'; | ||
public const TYPE_DATE = 'date'; | ||
public const TYPE_TIME = 'time'; | ||
public const TYPE_DATETIME = 'datetime'; | ||
/** | ||
* NEXT_MAJOR: Remove this constant. | ||
* | ||
* @deprecated since sonata-project/admin-bundle 3.68, to be removed in 4.0. Use Sonata\AdminBundle\Templating\TemplateRegistry::TYPE_STRING instead. | ||
*/ | ||
public const TYPE_TEXT = 'text'; | ||
public const TYPE_TEXTAREA = 'textarea'; | ||
public const TYPE_EMAIL = 'email'; | ||
public const TYPE_TRANS = 'trans'; | ||
public const TYPE_STRING = 'string'; | ||
/** | ||
* NEXT_MAJOR: Remove this constant. | ||
* | ||
* @deprecated since sonata-project/admin-bundle 3.68, to be removed in 4.0. Use Sonata\AdminBundle\Templating\TemplateRegistry::TYPE_INTEGER instead. | ||
*/ | ||
public const TYPE_SMALLINT = 'smallint'; | ||
/** | ||
* NEXT_MAJOR: Remove this constant. | ||
* | ||
* @deprecated since sonata-project/admin-bundle 3.68, to be removed in 4.0. Use Sonata\AdminBundle\Templating\TemplateRegistry::TYPE_INTEGER instead. | ||
*/ | ||
public const TYPE_BIGINT = 'bigint'; | ||
public const TYPE_INTEGER = 'integer'; | ||
/** | ||
* NEXT_MAJOR: Remove this constant. | ||
* NEXT_MAJOR: remove this method. | ||
* | ||
* @deprecated since sonata-project/admin-bundle 3.68, to be removed in 4.0. Use Sonata\AdminBundle\Templating\TemplateRegistry::TYPE_FLOAT instead. | ||
* @deprecated since version sonata-project/admin-bundle 3.39.0 and will be removed in 4.0. Use Sonata\AdminBundle\Templating\MutableTemplateRegistry instead. | ||
*/ | ||
public const TYPE_DECIMAL = 'decimal'; | ||
public const TYPE_FLOAT = 'float'; | ||
public const TYPE_IDENTIFIER = 'identifier'; | ||
public const TYPE_CURRENCY = 'currency'; | ||
public const TYPE_PERCENT = 'percent'; | ||
public const TYPE_CHOICE = 'choice'; | ||
public const TYPE_URL = 'url'; | ||
public const TYPE_HTML = 'html'; | ||
public const TYPE_MANY_TO_MANY = 'many_to_many'; | ||
public const TYPE_MANY_TO_ONE = 'many_to_one'; | ||
public const TYPE_ONE_TO_MANY = 'one_to_many'; | ||
public const TYPE_ONE_TO_ONE = 'one_to_one'; | ||
|
||
/** | ||
* @var array<string, string> | ||
*/ | ||
private $templates = []; | ||
|
||
/** | ||
* @param string[] $templates | ||
*/ | ||
public function __construct(array $templates = []) | ||
{ | ||
$this->templates = $templates; | ||
} | ||
|
||
public function getTemplates(): array | ||
{ | ||
return $this->templates; | ||
} | ||
|
||
public function setTemplates(array $templates) | ||
{ | ||
$this->templates = $templates; | ||
} | ||
|
||
public function hasTemplate(string $name): bool | ||
{ | ||
return isset($this->templates[$name]); | ||
@trigger_error(sprintf( | ||
'Method "%s()" is deprecated since sonata-admin/admin-bundle 3.39 and will be removed in 4.0.', | ||
__METHOD__ | ||
), E_USER_DEPRECATED); | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* NEXT_MAJOR: remove this method. | ||
* | ||
* @deprecated since version sonata-project/admin-bundle 3.39.0 and will be removed in 4.0. Use Sonata\AdminBundle\Templating\MutableTemplateRegistry instead. | ||
*/ | ||
public function getTemplate($name): ?string | ||
public function setTemplate($name, $template) | ||
{ | ||
if (isset($this->templates[$name])) { | ||
return $this->templates[$name]; | ||
} | ||
$this->templates[$name] = $template; | ||
|
||
@trigger_error(sprintf( | ||
'Passing a nonexistent template name as argument 1 to %s() is deprecated since' | ||
.' sonata-project/admin-bundle 3.52 and will throw an exception in 4.0.', | ||
'Method "%s()" is deprecated since sonata-admin/admin-bundle 3.39 and will be removed in 4.0.', | ||
__METHOD__ | ||
), E_USER_DEPRECATED); | ||
|
||
// NEXT_MAJOR : remove the previous `trigger_error()` call, the `return null` statement, uncomment the following exception and declare string as return type | ||
// throw new \InvalidArgumentException(sprintf( | ||
// 'Template named "%s" doesn\'t exist.', | ||
// $name | ||
// )); | ||
|
||
return null; | ||
} | ||
|
||
public function setTemplate($name, $template) | ||
{ | ||
$this->templates[$name] = $template; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,21 +14,20 @@ | |
namespace Sonata\AdminBundle\Templating; | ||
|
||
/** | ||
* /** | ||
* @author Wojciech Błoszyk <[email protected]> | ||
* | ||
* @method MutableTemplateRegistryInterface getTemplateRegistry() | ||
* @method bool hasTemplateRegistry() | ||
* @method void setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry) | ||
* @method TemplateRegistryInterface getTemplateRegistry() | ||
* @method bool hasTemplateRegistry() | ||
* @method void setTemplateRegistry(TemplateRegistryInterface $templateRegistry) | ||
*/ | ||
interface TemplateRegistryAwareInterface | ||
{ | ||
// NEXT_MAJOR: uncomment this method in 4.0 | ||
//public function getTemplateRegistry(): MutableTemplateRegistryInterface; | ||
//public function getTemplateRegistry(): TemplateRegistryInterface; | ||
|
||
// NEXT_MAJOR: uncomment this method in 4.0 | ||
//public function hasTemplateRegistry(): bool; | ||
|
||
// NEXT_MAJOR: uncomment this method in 4.0 | ||
//public function setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry): void; | ||
//public function setTemplateRegistry(TemplateRegistryInterface $templateRegistry): void; | ||
} |
Oops, something went wrong.