/** * Confirms that Object::add_static_var() doesn't work for uninherited stats */ public function testAddStaticVarDoesntWorkFor() { Object::add_static_var('ObjectStaticTest_First', 'first', array('test_1b')); Object::add_static_var('ObjectStaticTest_Second', 'first', array('test_2b')); $this->assertNotContains('test_1b', Object::uninherited_static('ObjectStaticTest_First', 'first')); $this->assertNotContains('test_2b', Object::uninherited_static('ObjectStaticTest_Second', 'first')); }
public function tearDown() { Object::add_static_var('GalleristPageDecorator', 'markup_template', $this->oldMarkupTemplate, true); Object::add_static_var('Page', 'gallerist_active', $this->oldGalleristActive, true); foreach($this->allFixtureIDs('Image') as $fileID) { $file = DataObject::get_by_id('Image', $fileID); $file->delete(); } parent::tearDown(); }
public static function add_sortable_many_many_relation($ownerClass, $componentName) { list($parentClass, $componentClass, $parentField, $componentField, $table) = singleton($ownerClass)->many_many($componentName); Object::add_static_var($ownerClass, 'many_many_extraFields', array($componentName => array('SortOrder' => 'Int'))); if (!isset(self::$many_many_sortable_relations[$componentClass])) { self::$many_many_sortable_relations[$componentClass] = array(); } self::$many_many_sortable_relations[$componentClass][$parentClass][] = $table; self::add_sortable_class($componentClass); }
/** * Checks that Object::add_static_var() also works for uninherited stats */ public function testAddStaticVarWorksForUninheritedStatics() { Object::add_static_var('ObjectStaticTest_First', 'first', array('test_1b')); Object::add_static_var('ObjectStaticTest_Second', 'first', array('test_2b')); // Check that it can be applied to parent and subclasses, and queried directly $this->assertContains('test_1b', Object::uninherited_static('ObjectStaticTest_First', 'first')); $this->assertContains('test_2b', Object::uninherited_static('ObjectStaticTest_Second', 'first')); // But it won't affect subclasses - this is *uninherited* static $this->assertNotContains('test_2b', Object::uninherited_static('ObjectStaticTest_Third', 'first')); $this->assertNotContains('test_2b', Object::uninherited_static('ObjectStaticTest_Fourth', 'first')); // Subclasses that don't have the static explicitly defined should allow definition, also // This also checks that add_static_var can be called after the first uninherited_static() // call (which can be buggy due to caching) Object::add_static_var('ObjectStaticTest_Fourth', 'first', array('test_4b')); $this->assertContains('test_4b', Object::uninherited_static('ObjectStaticTest_Fourth', 'first')); }
/** * Adds the ManyManySort column in the database table for the relationship. * Adds the parent many_many and relation name to $many_many_sortable_relations so * they can be used in ManyManySorted() * * @param DataObject with many_many * @param Relationship name */ public static function add_sortable_many_many_relation($ownerClass, $componentName) { Object::add_static_var($ownerClass, 'many_many_extraFields', array($componentName => array('ManyManySort' => 'Int'))); self::$many_many_sortable_relations[$ownerClass][$componentName]['relationName'] = $componentName; }
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // Janitor configuration specific for SilverStripes forum // module. Object::add_static_var('Forum', 'has_one_on_delete', array( 'Moderator' => 'set null', 'Group' => 'set null', 'Category' => 'set null' )); Object::add_static_var('ForumCategory', 'has_one_on_delete', array( 'ForumHolder' => 'set null' )); Object::add_static_var('ForumRole', 'has_one_on_delete', array( 'Avatar' => 'set null' )); Object::add_static_var('Post', 'has_one_on_delete', array( 'Forum' => 'set null', 'Author' => 'set null' ));
* * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Redema, nor the names of its contributors may be used * to endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // Janitor configuration specific for SilverStripes blog // module. Object::add_static_var('TrackBackPing', 'has_one_on_delete', array( 'Page' => 'delete' ));
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // Janitor configuration specific for SilverStripes user // forms module. Object::add_static_var('Member', 'has_many', array( '__Userforms_SubmittedForms' => 'SubmittedForm' )); Object::add_static_var('EditableFormField', 'has_one_on_delete', array( 'Parent' => 'delete' )); Object::add_static_var('SubmittedForm', 'has_one_on_delete', array( 'Parent' => 'delete', 'SubmittedBy' => 'set null' )); Object::add_static_var('SubmittedFormField', 'has_one_on_delete', array( 'Parent' => 'delete' ));
// Comments without an associated page can be removed since // their context is lost. Object::add_static_var('PageComment', 'has_one_on_delete', array( 'Parent' => 'delete', 'Author' => 'set null' )); // Deleted members do not need passwords. Object::add_static_var('MemberPassword', 'has_one_on_delete', array( 'Member' => 'delete' )); // Complete the SiteTree <=> Group many_many relationship. Object::add_static_var('Group', 'belongs_many_many', array( '__Janitor_ViewerSiteTrees' => 'SiteTree', '__Janitor_EditorSiteTrees' => 'SiteTree' )); // These intermediate tables must only be cleaned if the // "correct" side of the relation is being deleted to prevent // the cleaning from breaking SilverStripe functionality. DataObjectOnDeleteDecorator_ManyManyCleaner::set_one_way_tables(array_merge( array( // LinkTracking can only be cleaned when the deletion takes // place at the many_many side of relation. The relation // must be allowed to break in certain Versioned situations. 'SiteTree_LinkTracking' => 'LinkTracking', // Can only be cleaned when the SiteTree side of the relation // is deleted, since the relation must be allowed to break. 'SiteTree_ImageTracking' => 'ImageTracking' ), DataObjectOnDeleteDecorator_ManyManyCleaner::get_one_way_tables()