Re: [jcms] Digest for joomla-dev-cms@googlegroups.com - 1 update in 1 topic

53 views
Skip to first unread message

Joseph Cardwell

unread,
May 3, 2015, 4:52:53 PM5/3/15
to joomla-...@googlegroups.com
I've tried everything I can think of to effect the object that $document is pointing to in JApplicationSite::dispatch() but it appears to hold a copy of the JFactory::$document instance, not a reference to it. I can change the JFactory::$document to anything I want but since the JApplication ::$document is copied in the dispatch method, it no longer references the JApplication::$document object that I change in my component using JFactory::$application->loadDocument('mydoctype');

Later, then the document is render with JApplication::render(), it does render the correct document type, but its too late, becuase in JAppication::dispatch() the Document type that was copied in JApplicationSite::dispatch() is used to for setBuffer. So there is no way to stop JApplicationSite from setting the buffer using JDocumentHTML.

So later, if the value for the document body is stored incorrectly. In my case, rendering through JDocumentRaw, the component output in stored in $output['component] , when JDocumentRaw just wants a flat string to output, so the result is ARRAY, and strict error.

On Fri, May 1, 2015 at 11:05 PM, <joomla-...@googlegroups.com> wrote:
Joseph Cardwell <joseph....@jbcwebservices.com>: May 01 12:29PM -0700

Am I missing the benefit of locking in the JDocument during
JApplicationSite::dispatch(), BEFORE rendering the component. Waiting until
after the component is rendered would give the component control over the
JDocumentRenderer, and I don't see any dependencies that would be corrupted
by the change.
You have received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to joomla-dev-cm...@googlegroups.com.

Joseph Cardwell

unread,
May 3, 2015, 5:02:43 PM5/3/15
to joomla-...@googlegroups.com
form the php page on passing objects by reference, this seems relevant:

A reference is not a pointer. However, an object handle IS a pointer. Example:
<?php
class Foo {
  private static 
$used;
  private 
$id;
  public function 
__construct() {
    
$id $used++;
  }
  public function 
__clone() {
    
$id $used++;
  }
}

$a = new Foo// $a is a pointer pointing to Foo object 0
$b $a// $b is a pointer pointing to Foo object 0, however, $b is a copy of $a
$c = &$a// $c and $a are now references of a pointer pointing to Foo object 0
$a = new Foo// $a and $c are now references of a pointer pointing to Foo object 1, $b is still a pointer 

In JApplicationSite::dispatch(), for the assertion $document = $this->getDocument(), you are actually getting a copy of $this->document, pointing to the JDocumentHTML. When the JApplicationDocument is changed within the component, $document stil points to the old document object.

This is confirmed because if you pause execution at the point where renderComponent returns the $contents, if you change the document in your component, $document from the calling context till points to JDocumentHTML, while $this->document points to the new document you set in your component.
Reply all
Reply to author
Forward
0 new messages