Surely there must be a way to put both a composer compatible autoloader in the source tree, so that this can be put on packagist? I’m not sure I see how there would be a conflict with that one and the regular Yii autoloader, the latter which would simply be loading classes as usual and the composer one wouldn’t be used in this case. Thoughts?
Great, thanks I think it’s super easy, just have a look at https://github.com/Crisu83/yii-less or some other one of Crisu’s extensions to see an example.
I’ve recently started using Composer and it’s a real breeze to just add a line in your ‘require’ array and run composer update and have it all managed for you. Also easy to set up namespaces and autoloading.
Indeed that is very simple, I don’t even need to use the composer autoloader if I just have to provide configuration like that.
I’ll look into completing this today.
I have written a composer.json file now which should work but whenever I attempt to upload it to the packagist site it keeps saying they had a problem their end, I try to clean my browser session and re-log in but then I get a 500 error :\.
Is there an easy way to display validation errors of embedded documents and embedded arrays through CHtml::errorSummary($model) or CHtml::error($model)? How do you realize validation process in your applications?
It uses much the same setup as Yii but nested within the root document in array form. Hmmm, it seems that the error summary cannot just take a plain array which kinda sucks.
I might need to write an additional little function some where that can do what CHtml cannot.
CHtml::errorSummary() is designed to take instances of CModel, and EMongoModel extends from that class, hence it has getErrors() which is what errorSummary() use. What is the problem, can you not give it an instance of EMongoModel?
Also, I’d like to point out that EMongoModel shouldn’t override getErrors() since it doesn’t do anything that the parent equivalent doesn’t do. Removing this (and potentially other overriding methods that does the same thing as parent) can clean up the class a bit
The problem is that subdocuments are not enclosed in EMongoModel classes, they are simply arrays and the error summary functions do not recognise array nesting for errors.
Yea, however, if you check the comments above it you will realise that I added a new method which modified a private variable in the parent. PHP OO accession works in such a way that if you want to modify a parent variable directly that is of private scope you cannot. You have to duplicate all the code associated with that var whose functionality you wish to keep.
The only way to add errors to the var atm from the parent instance is to assume you are adding a message to a field and nothing else I don’t think, unless you mean something else?
To let people know, I will most likely start to remake MongoYii for Yii2 in the coming weeks/months (depending on how long it takes for the Yii team to say that the API etc is not going to change).
So I have full intention of porting MongoYii in its current form, hopefully without breaking too much, to Yii2
Due to how MongoDB works that won’t get a cursor but instead a MongoCollection object. This is fundamentally how the PHP driver works. If you want a MongoCursor to return you will need to use a read function like find or findOne
Yes it will only return a MongoCursor, what exactly are you trying to return? If you are trying to return all results from that collection then you can try iterator_to_array($cursor)
That made it! I didn’t even know about what iterators where. Gonna read more about it.
But, in another way how could I get that data without doing this? (as it was not mentioned elsewhere, I suppose there is another way of getting this data into a Yii view for example)
Thanks!
(by the way, I would recommend you to add a small note about it in the project Wiki and/or Github to help people that were looking specifically for this)