Textpattern | PHP Cross Reference | Content Management Systems |
Description: Provides the factory its own initialisation method.
1 <?php 2 3 /* 4 * Textpattern Content Management System 5 * http://textpattern.com 6 * 7 * Copyright (C) 2016 The Textpattern Development Team 8 * 9 * This file is part of Textpattern. 10 * 11 * Textpattern is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation, version 2. 14 * 15 * Textpattern is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with Textpattern. If not, see <http://www.gnu.org/licenses/>. 22 */ 23 24 /** 25 * Provides the factory its own initialisation method. 26 * 27 * The following will call 'getInstance()' method when creating new instance: 28 * 29 * <code> 30 * class Abc_Class implements \Textpattern\Container\FactorableInterface 31 * { 32 * public function getInstance() 33 * { 34 * echo 'Created instance'; 35 * return $this; 36 * } 37 * } 38 * Txp::get('Abc_Class'); 39 * </code> 40 * 41 * The above echoes 'Created instance' as the method is invoked. Keep in mind 42 * that implementing this interface doesn't prevent constructors from running, 43 * or let you to initialise private classes. It merely adds an additional method 44 * to the factory line. 45 * 46 * @since 4.6.0 47 * @package Container 48 */ 49 50 namespace Textpattern\Container; 51 52 interface FactorableInterface 53 { 54 /** 55 * Gets an instance of the class for the factory. 56 * 57 * @return \Textpattern\Container\FactorableInterface 58 */ 59 60 public function getInstance(); 61 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title