Package.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @package Grav\Common\GPM
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Common\GPM\Local;
  9. use Grav\Common\Data\Data;
  10. use Grav\Common\GPM\Common\Package as BasePackage;
  11. use Grav\Framework\Parsedown\Parsedown;
  12. class Package extends BasePackage
  13. {
  14. protected $settings;
  15. public function __construct(Data $package, $package_type = null)
  16. {
  17. $data = new Data($package->blueprints()->toArray());
  18. parent::__construct($data, $package_type);
  19. $this->settings = $package->toArray();
  20. $html_description = Parsedown::instance()->line($this->__get('description'));
  21. $this->data->set('slug', $package->__get('slug'));
  22. $this->data->set('description_html', $html_description);
  23. $this->data->set('description_plain', strip_tags($html_description));
  24. $this->data->set('symlink', is_link(USER_DIR . $package_type . DS . $this->__get('slug')));
  25. }
  26. /**
  27. * @return mixed
  28. */
  29. public function isEnabled()
  30. {
  31. return $this->settings['enabled'];
  32. }
  33. }