BaseMapper.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * This class is used to simulate the Form API.
  15. *
  16. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  17. */
  18. abstract class BaseMapper
  19. {
  20. /**
  21. * @var AdminInterface
  22. */
  23. protected $admin;
  24. /**
  25. * @var BuilderInterface
  26. */
  27. protected $builder;
  28. /**
  29. * @param BuilderInterface $builder
  30. * @param AdminInterface $admin
  31. */
  32. public function __construct(BuilderInterface $builder, AdminInterface $admin)
  33. {
  34. $this->builder = $builder;
  35. $this->admin = $admin;
  36. }
  37. /**
  38. * @return AdminInterface
  39. */
  40. public function getAdmin()
  41. {
  42. return $this->admin;
  43. }
  44. /**
  45. * @param string $key
  46. *
  47. * @return mixed
  48. */
  49. abstract public function get($key);
  50. /**
  51. * @param string $key
  52. *
  53. * @return bool
  54. */
  55. abstract public function has($key);
  56. /**
  57. * @param string $key
  58. *
  59. * @return $this
  60. */
  61. abstract public function remove($key);
  62. // To be uncommented on 4.0.
  63. /**
  64. * Returns configured keys.
  65. *
  66. * @return string[]
  67. */
  68. //abstract public function keys();
  69. /**
  70. * @param array $keys field names
  71. *
  72. * @return $this
  73. */
  74. abstract public function reorder(array $keys);
  75. }