Welcome, Guest
Username: Password: Remember me

TOPIC: Call to parent issue - I think

Call to parent issue - I think 16 Dec 2016 03:24 #14849

  • vlemos
  • vlemos's Avatar
  • Online
  • Elite Member
  • Posts: 295
  • Thank you received: 41
  • Karma: 21
Hello Admin / Cooks

I have a forked "replaced" controller class. However, I believe that the line:
	$this->_result = $result = parent::cancel();
is defeating my routine by referencing "parent". Has anyone had a similar experience in a controller?

In a rush towards a deadline and don't have the time to research it fully.

Feedback appreciated

Thanks alot
vlemos
The administrator has disabled public write access.

Call to parent issue - I think 17 Dec 2016 16:42 #14854

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 278
  • Thank you received: 35
  • Karma: 22
Yes, but it was a Fork View following this (found in the Fork Doc) :

Replace by one of the following possibilities :
   $this->_parentDisplay(); 
   self::_parentDisplay(); // Static call
   return self::_parentDisplay(); //Static call with returning value

but i really don't know if the method can be used in a Forked controler ???
Last Edit: 17 Dec 2016 16:55 by liubov.
The administrator has disabled public write access.
The following user(s) said Thank You: vlemos

Call to parent issue - I think 21 Dec 2016 19:46 #14859

  • vlemos
  • vlemos's Avatar
  • Online
  • Elite Member
  • Posts: 295
  • Thank you received: 41
  • Karma: 21
Hello liubov / cooks

The simplest solution I implemented was to call the class directly. However, I added a class alias to the constructor for "_parent" and then replace parent::cancel() with _parent::cancel(). Note: you must first determine the class being called by the child.

Hope this helps some other cook working with the fork controller classes.

Warm regards
V
	/**
	 * Constructor
	 *
	 * @access	public
	 * @param	array	$config	An optional associative array of configuration settings.
	 *
	 * @return	void
	 */
	public function __construct($config = array())
	{
		parent::__construct($config);
		$app = JFactory::getApplication();

		class_alias('TestCkClassControllerItem', '_parent');

	}
	//Usage 
	$this->_result = $result = _parent::cancel();
Last Edit: 21 Dec 2016 20:11 by vlemos.
The administrator has disabled public write access.

Call to parent issue - I think 22 Dec 2016 11:02 #14864

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 278
  • Thank you received: 35
  • Karma: 22
Hi,

Good way, simplest that i 've done,
Thanks Vlemos!
Last Edit: 22 Dec 2016 11:02 by liubov.
The administrator has disabled public write access.

Call to parent issue - I think 19 Jan 2017 22:50 #14957

  • vlemos
  • vlemos's Avatar
  • Online
  • Elite Member
  • Posts: 295
  • Thank you received: 41
  • Karma: 21
Hello Admin

The fork framework needs revisiting as it relates to the reference "parent". Once "parent::" is called within a forked class, execution passes to the main class and never returns. Therefore forking some routines is useless. For a forked field (cktext.php), when "return parent::getInput();" is called, the input property is overwritten by the main routine.
	/**
	* Method to get the field input markup.
	*
	* @access	public
	*
	*
	* @since	11.1
	*
	* @return	string	The field input markup.
	*/
	public function getInput()
	{

		$this->input = JDom::_('html.form.input.text', array_merge(array(
				'dataKey' => $this->getOption('name'),
				'domClass' => $this->getOption('class'),
				'domId' => $this->id,
				'domName' => $this->name,
				'dataValue' => $this->value,
		'testValue' => $this->test,
				'placeholder' => $this->getOption('placeholder'),
				'prefix' => $this->getOption('prefix'),
				'responsive' => $this->getOption('responsive'),
				'size' => $this->getOption('size'),
				'suffix' => $this->getOption('suffix')
			), $this->jdomOptions));

		return parent::getInput();
	}
Please look into this and let me know if it can be easily fixed across components.

Warm regards
vlemos
The administrator has disabled public write access.
Time to create page: 0.081 seconds

Get Started