BaseMapper.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\AdminBundle\Mapper;
  11. use Sonata\AdminBundle\Admin\AdminInterface;
  12. use Sonata\AdminBundle\Builder\BuilderInterface;
  13. /**
  14. * Class BaseMapper
  15. * This class is used to simulate the Form API.
  16. *
  17. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  18. */
  19. abstract class BaseMapper
  20. {
  21. /**
  22. * @var AdminInterface
  23. */
  24. protected $admin;
  25. /**
  26. * @var BuilderInterface
  27. */
  28. protected $builder;
  29. /**
  30. * @param BuilderInterface $builder
  31. * @param AdminInterface $admin
  32. */
  33. public function __construct(BuilderInterface $builder, AdminInterface $admin)
  34. {
  35. $this->builder = $builder;
  36. $this->admin = $admin;
  37. }
  38. /**
  39. * @return AdminInterface
  40. */
  41. public function getAdmin()
  42. {
  43. return $this->admin;
  44. }
  45. /**
  46. * @param string $key
  47. *
  48. * @return mixed
  49. */
  50. abstract public function get($key);
  51. /**
  52. * @param string $key
  53. *
  54. * @return bool
  55. */
  56. abstract public function has($key);
  57. /**
  58. * @param string $key
  59. *
  60. * @return $this
  61. */
  62. abstract public function remove($key);
  63. // To be uncommented on 4.0.
  64. /**
  65. * Returns configured keys.
  66. *
  67. * @return string[]
  68. */
  69. //abstract public function keys();
  70. /**
  71. * @param array $keys field names
  72. *
  73. * @return $this
  74. */
  75. abstract public function reorder(array $keys);
  76. }