Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Added form annotation builder factory #6712

Closed
wants to merge 9 commits into from

Conversation

carnage
Copy link
Contributor

@carnage carnage commented Sep 28, 2014

Two outstanding items for this pull request:

  1. What is the best method to get it into the default service locator config?
  2. Should the factory support adding custom annotations and annotation listeners to the builder?

@@ -0,0 +1,38 @@
<?php

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license header here

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

@prolic
Copy link
Contributor

prolic commented Sep 30, 2014

Can you add the form annoation builder factory to the preconfigured stack?

@carnage
Copy link
Contributor Author

carnage commented Oct 1, 2014

That was one of the outstanding questions: where is it best to add it to to get it into the preconfigured stack? My initial guess was in Zend\Mvc\Service\ServiceManagerConfig, however there seems to be very few classes configured in there so I was wondering if there was a better place?

@prolic
Copy link
Contributor

prolic commented Oct 1, 2014

Perhabs in the skeleton application? Just my thoughts.

@carnage
Copy link
Contributor Author

carnage commented Oct 12, 2014

Added it to the ServiceListenerFactory, which is where most of the other default MVC factories are.

@carnage
Copy link
Contributor Author

carnage commented Oct 12, 2014

Ive added methods to allow for setting up custom annotations and listeners in the config. There are no tests yet, but if everyone agrees with the methodology used, I'll create some tests and this PR will be complete.

@carnage
Copy link
Contributor Author

carnage commented Oct 12, 2014

If/When this PR is accepted: #6754 there is an addition to this PR to allow setting of options for the Annotation builder see this branch:
https://github.com/carnage/zf2/tree/annotation-factory-options

@prolic
Copy link
Contributor

prolic commented Nov 10, 2014

Good to merge for me!

@carnage carnage changed the title [WIP] Added form annotation builder factory Added form annotation builder factory Nov 18, 2014
* @param $fullyQualifiedClassName
* @return $this
*/
public function registerAnnotation($fullyQualifiedClassName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a SRP violation: simply inject a configured parser instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the parser implementation details are internal to the class, before this enhancement the parser was created inside setAnnotationManager and populated by this class with some default annotations - hiding this complexity from client code.

Whilst I agree that this does seem to be a SRP violation, resolving the violation would be a significant BC break.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but you are already solving this issue via configuration and a factory, no? Can't the factory hide this additional complexity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm solving the complexity of adding custom annotations to the parser using the Factory + config, however the default ones are added by the class.

Current use case for this class is to call new FormAnnotationBuilder in consuming code; prior to this change, it wasn't registered with the service locator. Moving the default annotation registering into the factory would leave code which instantiates directly with an incomplete parser class.

The default annotations could be moved into the factory but doing so would be a big BC break, which would mean this needs to be bumped to v 3.0.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you grab the AnnotationParser parser from the AnnotationBuilder inside the factory and registerAnnotation() on it instead?

@carnage
Copy link
Contributor Author

carnage commented Dec 27, 2014

Made all the changes you requested; not sure why the build is failing?

}

return $this->annotationParser;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this abstraction is necessary, if there's no way to inject the parser otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 yes, normal getters and setters are possible. inject the parser in the factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this were to be removedit would break bc -> users would have to instantiate via the factory or risk not having a parser

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carnage I missed that it was being used in the factory as well, and, as such, is part of the public API you need to expose. We can keep it as-is.

@weierophinney weierophinney added this to the 2.4.0 milestone Feb 19, 2015
weierophinney added a commit that referenced this pull request Feb 23, 2015
Added form annotation builder factory

Conflicts:
	library/Zend/Mvc/Service/ServiceListenerFactory.php
weierophinney added a commit that referenced this pull request Feb 23, 2015
weierophinney added a commit that referenced this pull request Feb 23, 2015
@weierophinney
Copy link
Member

Merged to develop for release with 2.4.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants