namespacing documentation and many_many question

35 views
Skip to first unread message

Nicolaas Thiemen Francken - Sunny Side Up

unread,
May 22, 2014, 6:48:41 AM5/22/14
to silverstripe-dev
Hi Everyone

I know this is not really the place for little questions - but namespacing is kind of trendy right now ;-)

Is it correct that there is no documentation around SS and namespaces?

Right now I am trying to work out how to do a many_many relationship...

------------------------------------------
Class MyClassWithoutNameSpace
private static $many_many = array(
"Industries" => "\DP\Industry"
);

}

------------------------------------------
namespace DP;

class Industry extends \DataObject  {

private static $belongs_many_many = array(
"MyClassWithoutNameSpaces" => "\MyClassWithoutNameSpace"
);

that does not work...

I am sure this is simple. Can someone point me in the right direction and also - are there any plans for documentations on namespaces?

THANK YOU

Nicolaas

Fred Condo

unread,
May 22, 2014, 1:15:25 PM5/22/14
to Nicolaas Thiemen Francken - Sunny Side Up, silverst...@googlegroups.com


On May 22, 2014 at 3:48:42 , Nicolaas Thiemen Francken - Sunny Side Up (nfra...@gmail.com) wrote:

Hi Everyone

I know this is not really the place for little questions - but namespacing is kind of trendy right now ;-)

Is it correct that there is no documentation around SS and namespaces?

Right now I am trying to work out how to do a many_many relationship...

------------------------------------------
Class MyClassWithoutNameSpace
private static $many_many = array(
"Industries" => "\DP\Industry"
);

}

------------------------------------------
namespace DP;

class Industry extends \DataObject  {

private static $belongs_many_many = array(
"MyClassWithoutNameSpaces" => "\MyClassWithoutNameSpace"
);


At a minimum, you will have to escape the backslash: "\\MyClassWithoutNameSpace"

I do not assert that this will then work, because I have not yet tried to use PHP namespaces in SilverStripe.

Nicolaas Thiemen Francken - Sunny Side Up

unread,
May 22, 2014, 5:11:41 PM5/22/14
to Fred Condo, silverstripe-dev
Hi Fred

Tried several variations, but could not make it work.  I am sure it is something very stupid and simple and hence I reckon it would be great to have some basic recipes for namespacing. Here are some discussions I found:

They seem to be open ended.  Several people report using namespaces with great success. 

Anyone has some recipes? 

Nicolaas



Jeremy Shipman

unread,
May 29, 2014, 6:13:51 PM5/29/14
to silverst...@googlegroups.com, silverstripe-dev
I don’t namespace anything that extends DataModel, as I have not heard anything about this being supported. Particularly because the class name is stored in the database.

Jeremy
--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.

Nicolaas Thiemen Francken - Sunny Side Up

unread,
Jun 1, 2014, 10:54:27 PM6/1/14
to silverstripe-dev
On 30 May 2014 10:13, Jeremy Shipman <jer...@burnbright.net> wrote:
I don’t namespace anything that extends DataModel, as I have not heard anything about this being supported. Particularly because the class name is stored in the database.

It seemed to work ;-) most of it anyway... 
Reply all
Reply to author
Forward
0 new messages