1 | <?php |
||
12 | class SlugableExtension extends \DataExtension { |
||
13 | private static $db = [ |
||
14 | 'URLSegment' => 'Varchar(200)' |
||
15 | ]; |
||
16 | |||
17 | private static $indexes = [ |
||
18 | "URLSegment" => [ |
||
19 | 'type' => 'unique', |
||
20 | 'value' => 'URLSegment' |
||
21 | ] |
||
22 | ]; |
||
23 | |||
24 | private static $defaults = [ |
||
25 | 'Title' => 'New Element', |
||
26 | 'URLSegment' => 'new-element' |
||
27 | ]; |
||
28 | |||
29 | |||
30 | /** |
||
31 | * Set URLSegment to be unique on write |
||
32 | */ |
||
33 | public function onBeforeWrite() { |
||
61 | |||
62 | /** |
||
63 | * Check if there is already a database entry with this url segment |
||
64 | * |
||
65 | * @param string $urlSegment |
||
66 | * @param int $id |
||
67 | * @return bool |
||
68 | */ |
||
69 | protected function lookForExistingURLSegment($urlSegment, $id) { |
||
74 | |||
75 | /** |
||
76 | * Generate a URL segment based on the title provided. |
||
77 | * |
||
78 | * If {@link Extension}s wish to alter URL segment generation, they can do so by defining |
||
79 | * updateURLSegment(&$url, $title). $url will be passed by reference and should be modified. |
||
80 | * $title will contain the title that was originally used as the source of this generated URL. |
||
81 | * This lets extensions either start from scratch, or incrementally modify the generated URL. |
||
82 | * |
||
83 | * @param string $title the given title |
||
84 | * @return string generated url segment |
||
85 | */ |
||
86 | public function generateURLSegment($title) { |
||
97 | |||
98 | private function fallbackUrl() { |
||
102 | |||
103 | } |
||
104 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.