From 93abd192a8cc684475d1ed3a9b06d3f2166099be Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 11:46:05 +0100 Subject: [PATCH 001/210] Bundle generation --- ChillReportBundle.php | 9 + Controller/DefaultController.php | 13 + DependencyInjection/ChillReportExtension.php | 28 + DependencyInjection/Configuration.php | 29 + LICENSE | 661 +++++++++++++++++++ README.md | 4 + Resources/config/routing.yml | 3 + Resources/config/services.yml | 4 + Resources/views/Default/index.html.twig | 1 + Tests/Controller/DefaultControllerTest.php | 17 + 10 files changed, 769 insertions(+) create mode 100644 ChillReportBundle.php create mode 100644 Controller/DefaultController.php create mode 100644 DependencyInjection/ChillReportExtension.php create mode 100644 DependencyInjection/Configuration.php create mode 100644 LICENSE create mode 100644 README.md create mode 100644 Resources/config/routing.yml create mode 100644 Resources/config/services.yml create mode 100644 Resources/views/Default/index.html.twig create mode 100644 Tests/Controller/DefaultControllerTest.php diff --git a/ChillReportBundle.php b/ChillReportBundle.php new file mode 100644 index 000000000..967796d8b --- /dev/null +++ b/ChillReportBundle.php @@ -0,0 +1,9 @@ +render('ChillReportBundle:Default:index.html.twig', array('name' => $name)); + } +} diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php new file mode 100644 index 000000000..7e3506b5b --- /dev/null +++ b/DependencyInjection/ChillReportExtension.php @@ -0,0 +1,28 @@ +processConfiguration($configuration, $configs); + + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.yml'); + } +} diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php new file mode 100644 index 000000000..e9c959146 --- /dev/null +++ b/DependencyInjection/Configuration.php @@ -0,0 +1,29 @@ +root('chill_report'); + + // Here you should define the parameters that are allowed to + // configure your bundle. See the documentation linked above for + // more information on that topic. + + return $treeBuilder; + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..dba13ed2d --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 000000000..250ed17ef --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +ChillReport +=========== + +The bundle for reports \ No newline at end of file diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml new file mode 100644 index 000000000..b2452ae9a --- /dev/null +++ b/Resources/config/routing.yml @@ -0,0 +1,3 @@ +chill_report_homepage: + path: /hello/{name} + defaults: { _controller: ChillReportBundle:Default:index } diff --git a/Resources/config/services.yml b/Resources/config/services.yml new file mode 100644 index 000000000..73a6dafca --- /dev/null +++ b/Resources/config/services.yml @@ -0,0 +1,4 @@ +services: +# chill_report.example: +# class: Chill\ReportBundle\Example +# arguments: [@service_id, "plain_value", %parameter%] diff --git a/Resources/views/Default/index.html.twig b/Resources/views/Default/index.html.twig new file mode 100644 index 000000000..4ce626e9b --- /dev/null +++ b/Resources/views/Default/index.html.twig @@ -0,0 +1 @@ +Hello {{ name }}! diff --git a/Tests/Controller/DefaultControllerTest.php b/Tests/Controller/DefaultControllerTest.php new file mode 100644 index 000000000..3ab2fb41c --- /dev/null +++ b/Tests/Controller/DefaultControllerTest.php @@ -0,0 +1,17 @@ +request('GET', '/hello/Fabien'); + + $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0); + } +} From bd82733a6c522b7d3d3afc6b9e0ae0b9f785d55e Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 11:56:28 +0100 Subject: [PATCH 002/210] Adding composer.json --- .gitignore | 1 + composer.json | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..57872d0f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vendor/ diff --git a/composer.json b/composer.json new file mode 100644 index 000000000..a25841d41 --- /dev/null +++ b/composer.json @@ -0,0 +1,32 @@ +{ + "name": "chill-project/report", + "description": "The bundle for reports", + "type": "symfony-bundle", + "keywords" : ["chill", "social work"], + "license": "AGPL-3.0", + "homepage" : "https://github.com/Chill-project/Report", + "authors" : [ + { + "name": "Champs-Libres", + "email": "info@champs-libres.coop", + "homepage": "http://www.champs-libres.coop" + } + ], + "require": { + "twig/extensions": "~1.0", + "symfony/assetic-bundle": "~2.3", + "symfony/monolog-bundle": "~2.4", + "symfony/framework-bundle": "2.5.*", + "symfony/yaml": "2.5.*", + "symfony/symfony": "2.5.*", + "doctrine/dbal": "2.5.*@dev", + "doctrine/orm": "2.5.*@dev", + "doctrine/common": "2.4.*@dev", + "doctrine/doctrine-bundle": "~1.2@dev" + }, + "require-dev": { + "symfony/dom-crawler": "2.5", + "doctrine/doctrine-fixtures-bundle": "~2.2", + "symfony/security": "~2.5" + } +} From a911c7aeae0ed53b94a6ce0bb598822d19c4ec3e Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 15:32:21 +0100 Subject: [PATCH 003/210] Adding Tests --- Tests/Fixtures/.DS_Store | Bin 0 -> 6148 bytes Tests/Fixtures/App/AppKernel.php | 37 + Tests/Fixtures/App/config/config.yml | 12 + Tests/Fixtures/App/config/config_dev.yml | 7 + Tests/Fixtures/App/config/config_test.yml | 7 + Tests/Fixtures/App/config/routing.yml | 1 + Tests/Fixtures/App/console | 27 + Tests/bootstrap.php | 7 + composer.json | 8 +- composer.lock | 1363 +++++++++++++++++++++ console.sh | 1 + phpunit.xml.dist | 20 + 12 files changed, 1485 insertions(+), 5 deletions(-) create mode 100644 Tests/Fixtures/.DS_Store create mode 100644 Tests/Fixtures/App/AppKernel.php create mode 100644 Tests/Fixtures/App/config/config.yml create mode 100644 Tests/Fixtures/App/config/config_dev.yml create mode 100644 Tests/Fixtures/App/config/config_test.yml create mode 100644 Tests/Fixtures/App/config/routing.yml create mode 100644 Tests/Fixtures/App/console create mode 100644 Tests/bootstrap.php create mode 100644 composer.lock create mode 100755 console.sh create mode 100644 phpunit.xml.dist diff --git a/Tests/Fixtures/.DS_Store b/Tests/Fixtures/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); + } + + /** + * @return string + */ + public function getCacheDir() + { + return sys_get_temp_dir().'/ChillReportBundle/cache'; + } + + /** + * @return string + */ + public function getLogDir() + { + return sys_get_temp_dir().'/ChillReportBundle/logs'; + } +} diff --git a/Tests/Fixtures/App/config/config.yml b/Tests/Fixtures/App/config/config.yml new file mode 100644 index 000000000..e0b6e919f --- /dev/null +++ b/Tests/Fixtures/App/config/config.yml @@ -0,0 +1,12 @@ +# config/config.yml +framework: + secret: Not very secret + router: { resource: "%kernel.root_dir%/config/routing.yml" } + form: true + csrf_protection: true + session: ~ + default_locale: fr + translator: { fallback: fr } + profiler: { only_exceptions: false } + templating: #required for assetic. Remove if not needed + engines: ['twig'] \ No newline at end of file diff --git a/Tests/Fixtures/App/config/config_dev.yml b/Tests/Fixtures/App/config/config_dev.yml new file mode 100644 index 000000000..81e0f80f4 --- /dev/null +++ b/Tests/Fixtures/App/config/config_dev.yml @@ -0,0 +1,7 @@ +imports: + - { resource: config.yml } #here we import a config.yml file, this is not required + +framework: + test: ~ + session: + storage_id: session.storage.filesystem \ No newline at end of file diff --git a/Tests/Fixtures/App/config/config_test.yml b/Tests/Fixtures/App/config/config_test.yml new file mode 100644 index 000000000..81e0f80f4 --- /dev/null +++ b/Tests/Fixtures/App/config/config_test.yml @@ -0,0 +1,7 @@ +imports: + - { resource: config.yml } #here we import a config.yml file, this is not required + +framework: + test: ~ + session: + storage_id: session.storage.filesystem \ No newline at end of file diff --git a/Tests/Fixtures/App/config/routing.yml b/Tests/Fixtures/App/config/routing.yml new file mode 100644 index 000000000..e525ae9d4 --- /dev/null +++ b/Tests/Fixtures/App/config/routing.yml @@ -0,0 +1 @@ +routing.yml \ No newline at end of file diff --git a/Tests/Fixtures/App/console b/Tests/Fixtures/App/console new file mode 100644 index 000000000..2b45f964b --- /dev/null +++ b/Tests/Fixtures/App/console @@ -0,0 +1,27 @@ +#!/usr/bin/env php +getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev'); +$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod'; + +if ($debug) { + Debug::enable(); +} + +$kernel = new AppKernel($env, $debug); +$application = new Application($kernel); +$application->run($input); diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php new file mode 100644 index 000000000..2437ecd2d --- /dev/null +++ b/Tests/bootstrap.php @@ -0,0 +1,7 @@ +=5.3.2" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2014-09-25 16:45:30" + }, + { + "name": "doctrine/cache", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/cf483685798a72c93bf4206e3dd6358ea07d64e7", + "reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "phpunit/phpunit": ">=3.7", + "satooshi/php-coveralls": "~0.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Cache\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ], + "time": "2014-09-17 14:24:04" + }, + { + "name": "doctrine/collections", + "version": "v1.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "b99c5c46c87126201899afe88ec490a25eedd6a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/b99c5c46c87126201899afe88ec490a25eedd6a2", + "reference": "b99c5c46c87126201899afe88ec490a25eedd6a2", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "array", + "collections", + "iterator" + ], + "time": "2014-02-03 23:07:43" + }, + { + "name": "doctrine/common", + "version": "2.4.x-dev", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "ae92d076442e27b6910dd86a1292a8867cf5cfe4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/ae92d076442e27b6910dd86a1292a8867cf5cfe4", + "reference": "ae92d076442e27b6910dd86a1292a8867cf5cfe4", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ], + "time": "2014-05-21 19:29:23" + }, + { + "name": "doctrine/dbal", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "ec6da750f9d3ee83f26fe921a9c57fdda73f07a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/ec6da750f9d3ee83f26fe921a9c57fdda73f07a0", + "reference": "ec6da750f9d3ee83f26fe921a9c57fdda73f07a0", + "shasum": "" + }, + "require": { + "doctrine/common": ">=2.4,<2.6-dev", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "symfony/console": "2.*" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\DBAL\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Database Abstraction Layer", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "dbal", + "persistence", + "queryobject" + ], + "time": "2014-11-07 10:05:10" + }, + { + "name": "doctrine/doctrine-bundle", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/doctrine/DoctrineBundle.git", + "reference": "d9763ccbb637958133c42bdcc3d31c5a6821b9e2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/d9763ccbb637958133c42bdcc3d31c5a6821b9e2", + "reference": "d9763ccbb637958133c42bdcc3d31c5a6821b9e2", + "shasum": "" + }, + "require": { + "doctrine/dbal": "~2.3", + "doctrine/doctrine-cache-bundle": "~1.0", + "jdorn/sql-formatter": "~1.1", + "php": ">=5.3.2", + "symfony/doctrine-bridge": "~2.2", + "symfony/framework-bundle": "~2.2" + }, + "require-dev": { + "doctrine/orm": "~2.3", + "phpunit/php-code-coverage": "~1.2", + "phpunit/phpunit": "~3.7", + "phpunit/phpunit-mock-objects": "~1.2", + "satooshi/php-coveralls": "~0.6.1", + "symfony/validator": "~2.2", + "symfony/yaml": "~2.2", + "twig/twig": "~1" + }, + "suggest": { + "doctrine/orm": "The Doctrine ORM integration is optional in the bundle.", + "symfony/web-profiler-bundle": "to use the data collector" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Bundle\\DoctrineBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Doctrine Project", + "homepage": "http://www.doctrine-project.org/" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony DoctrineBundle", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "dbal", + "orm", + "persistence" + ], + "time": "2014-10-04 16:13:24" + }, + { + "name": "doctrine/doctrine-cache-bundle", + "version": "1.0.0", + "target-dir": "Doctrine/Bundle/DoctrineCacheBundle", + "source": { + "type": "git", + "url": "https://github.com/doctrine/DoctrineCacheBundle.git", + "reference": "49a9d2d9a35863201e5e608d1194db28946c4552" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/DoctrineCacheBundle/zipball/49a9d2d9a35863201e5e608d1194db28946c4552", + "reference": "49a9d2d9a35863201e5e608d1194db28946c4552", + "shasum": "" + }, + "require": { + "doctrine/cache": "~1.3", + "doctrine/inflector": "~1.0", + "php": ">=5.3.2", + "symfony/doctrine-bridge": "~2.2", + "symfony/framework-bundle": "~2.2", + "symfony/security": "~2.2" + }, + "require-dev": { + "instaclick/coding-standard": "~1.1", + "instaclick/object-calisthenics-sniffs": "dev-master", + "instaclick/symfony2-coding-standard": "dev-remaster", + "phpunit/phpunit": "~3.7", + "satooshi/php-coveralls": "~0.6.1", + "squizlabs/php_codesniffer": "dev-master", + "symfony/validator": "~2.2", + "symfony/yaml": "~2.2" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Bundle\\DoctrineCacheBundle": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Fabio B. Silva", + "email": "fabio.bat.silva@gmail.com" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@hotmail.com" + }, + { + "name": "Doctrine Project", + "homepage": "http://www.doctrine-project.org/" + } + ], + "description": "Symfony2 Bundle for Doctrine Cache", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ], + "time": "2014-03-04 19:18:55" + }, + { + "name": "doctrine/inflector", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "54b8333d2a5682afdc690060c1cf384ba9f47f08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/54b8333d2a5682afdc690060c1cf384ba9f47f08", + "reference": "54b8333d2a5682afdc690060c1cf384ba9f47f08", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Inflector\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluarlize", + "singuarlize", + "string" + ], + "time": "2013-01-10 21:49:15" + }, + { + "name": "doctrine/instantiator", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-10-13 12:58:55" + }, + { + "name": "doctrine/lexer", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/2f708a85bb3aab5d99dab8be435abd73e0b18acb", + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2013-01-12 18:59:04" + }, + { + "name": "doctrine/orm", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/doctrine/doctrine2.git", + "reference": "76e1a469ef3c4af4ef9d60c769822d4283809217" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/76e1a469ef3c4af4ef9d60c769822d4283809217", + "reference": "76e1a469ef3c4af4ef9d60c769822d4283809217", + "shasum": "" + }, + "require": { + "doctrine/collections": "~1.2", + "doctrine/dbal": ">=2.5-dev,<2.6-dev", + "doctrine/instantiator": "~1.0.1", + "ext-pdo": "*", + "php": ">=5.3.2", + "symfony/console": "~2.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", + "symfony/yaml": "~2.1" + }, + "suggest": { + "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" + }, + "bin": [ + "bin/doctrine", + "bin/doctrine.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\ORM\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Object-Relational-Mapper for PHP", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "orm" + ], + "time": "2014-11-05 12:19:29" + }, + { + "name": "jdorn/sql-formatter", + "version": "v1.2.17", + "source": { + "type": "git", + "url": "https://github.com/jdorn/sql-formatter.git", + "reference": "64990d96e0959dff8e059dfcdc1af130728d92bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jdorn/sql-formatter/zipball/64990d96e0959dff8e059dfcdc1af130728d92bc", + "reference": "64990d96e0959dff8e059dfcdc1af130728d92bc", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "lib" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jeremy Dorn", + "email": "jeremy@jeremydorn.com", + "homepage": "http://jeremydorn.com/" + } + ], + "description": "a PHP SQL highlighting library", + "homepage": "https://github.com/jdorn/sql-formatter/", + "keywords": [ + "highlight", + "sql" + ], + "time": "2014-01-12 16:20:24" + }, + { + "name": "kriswallsmith/assetic", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/kriswallsmith/assetic.git", + "reference": "df991c124a2212371443b586a1be767500036dee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/df991c124a2212371443b586a1be767500036dee", + "reference": "df991c124a2212371443b586a1be767500036dee", + "shasum": "" + }, + "require": { + "php": ">=5.3.1", + "symfony/process": "~2.1" + }, + "require-dev": { + "cssmin/cssmin": "*", + "joliclic/javascript-packer": "*", + "kamicane/packager": "*", + "leafo/lessphp": "*", + "leafo/scssphp": "*", + "leafo/scssphp-compass": "*", + "mrclay/minify": "*", + "patchwork/jsqueeze": "~1.0", + "phpunit/phpunit": "~4", + "psr/log": "~1.0", + "ptachoire/cssembed": "*", + "twig/twig": "~1.6" + }, + "suggest": { + "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", + "leafo/scssphp": "Assetic provides the integration with the scssphp SCSS compiler", + "leafo/scssphp-compass": "Assetic provides the integration with the SCSS compass plugin", + "patchwork/jsqueeze": "Assetic provides the integration with the JSqueeze JavaScript compressor", + "ptachoire/cssembed": "Assetic provides the integration with phpcssembed to embed data uris", + "twig/twig": "Assetic provides the integration with the Twig templating engine" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "psr-0": { + "Assetic": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kris Wallsmith", + "email": "kris.wallsmith@gmail.com", + "homepage": "http://kriswallsmith.net/" + } + ], + "description": "Asset Management for PHP", + "homepage": "https://github.com/kriswallsmith/assetic", + "keywords": [ + "assets", + "compression", + "minification" + ], + "time": "2014-10-14 14:45:32" + }, + { + "name": "monolog/monolog", + "version": "1.11.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "ec3961874c43840e96da3a8a1ed20d8c73d7e5aa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/ec3961874c43840e96da3a8a1ed20d8c73d7e5aa", + "reference": "ec3961874c43840e96da3a8a1ed20d8c73d7e5aa", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "provide": { + "psr/log-implementation": "1.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "~2.4, >2.4.8", + "doctrine/couchdb": "~1.0@dev", + "graylog2/gelf-php": "~1.0", + "phpunit/phpunit": "~3.7.0", + "raven/raven": "~0.5", + "ruflin/elastica": "0.90.*", + "videlalvaro/php-amqplib": "~2.4" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "raven/raven": "Allow sending log messages to a Sentry server", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server", + "videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "http://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "time": "2014-09-30 13:30:58" + }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "symfony/assetic-bundle", + "version": "v2.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/AsseticBundle.git", + "reference": "90ea7fb66d6d5245fd4afc16e4c8070214254fec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/AsseticBundle/zipball/90ea7fb66d6d5245fd4afc16e4c8070214254fec", + "reference": "90ea7fb66d6d5245fd4afc16e4c8070214254fec", + "shasum": "" + }, + "require": { + "kriswallsmith/assetic": "~1.2", + "php": ">=5.3.0", + "symfony/console": "~2.1", + "symfony/framework-bundle": "~2.1", + "symfony/yaml": "~2.1" + }, + "require-dev": { + "kriswallsmith/spork": "~0.2", + "patchwork/jsqueeze": "~1.0", + "symfony/class-loader": "~2.1", + "symfony/css-selector": "~2.1", + "symfony/dom-crawler": "~2.1", + "symfony/twig-bundle": "~2.1" + }, + "suggest": { + "kriswallsmith/spork": "to be able to dump assets in parallel", + "symfony/twig-bundle": "to use the Twig integration" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Bundle\\AsseticBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kris Wallsmith", + "email": "kris.wallsmith@gmail.com", + "homepage": "http://kriswallsmith.net/" + } + ], + "description": "Integrates Assetic into Symfony2", + "homepage": "https://github.com/symfony/AsseticBundle", + "keywords": [ + "assets", + "compression", + "minification" + ], + "time": "2014-10-15 12:03:38" + }, + { + "name": "symfony/monolog-bundle", + "version": "v2.6.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/MonologBundle.git", + "reference": "227bbeefe30f2d95e3fe5fbd1ccda414287a957a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/MonologBundle/zipball/227bbeefe30f2d95e3fe5fbd1ccda414287a957a", + "reference": "227bbeefe30f2d95e3fe5fbd1ccda414287a957a", + "shasum": "" + }, + "require": { + "monolog/monolog": "~1.8", + "php": ">=5.3.2", + "symfony/config": "~2.3", + "symfony/dependency-injection": "~2.3", + "symfony/http-kernel": "~2.3", + "symfony/monolog-bridge": "~2.3" + }, + "require-dev": { + "symfony/console": "~2.3", + "symfony/yaml": "~2.3" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "2.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Bundle\\MonologBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony MonologBundle", + "homepage": "http://symfony.com", + "keywords": [ + "log", + "logging" + ], + "time": "2014-07-21 00:36:06" + }, + { + "name": "symfony/symfony", + "version": "v2.5.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/symfony.git", + "reference": "1a1b1e528935f15dd76169f8b1dc3ef97f0d6210" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/symfony/zipball/1a1b1e528935f15dd76169f8b1dc3ef97f0d6210", + "reference": "1a1b1e528935f15dd76169f8b1dc3ef97f0d6210", + "shasum": "" + }, + "require": { + "doctrine/common": "~2.2", + "php": ">=5.3.3", + "psr/log": "~1.0", + "twig/twig": "~1.12" + }, + "replace": { + "symfony/browser-kit": "self.version", + "symfony/class-loader": "self.version", + "symfony/config": "self.version", + "symfony/console": "self.version", + "symfony/css-selector": "self.version", + "symfony/debug": "self.version", + "symfony/dependency-injection": "self.version", + "symfony/doctrine-bridge": "self.version", + "symfony/dom-crawler": "self.version", + "symfony/event-dispatcher": "self.version", + "symfony/expression-language": "self.version", + "symfony/filesystem": "self.version", + "symfony/finder": "self.version", + "symfony/form": "self.version", + "symfony/framework-bundle": "self.version", + "symfony/http-foundation": "self.version", + "symfony/http-kernel": "self.version", + "symfony/intl": "self.version", + "symfony/locale": "self.version", + "symfony/monolog-bridge": "self.version", + "symfony/options-resolver": "self.version", + "symfony/process": "self.version", + "symfony/propel1-bridge": "self.version", + "symfony/property-access": "self.version", + "symfony/proxy-manager-bridge": "self.version", + "symfony/routing": "self.version", + "symfony/security": "self.version", + "symfony/security-acl": "self.version", + "symfony/security-bundle": "self.version", + "symfony/security-core": "self.version", + "symfony/security-csrf": "self.version", + "symfony/security-http": "self.version", + "symfony/serializer": "self.version", + "symfony/stopwatch": "self.version", + "symfony/swiftmailer-bridge": "self.version", + "symfony/templating": "self.version", + "symfony/translation": "self.version", + "symfony/twig-bridge": "self.version", + "symfony/twig-bundle": "self.version", + "symfony/validator": "self.version", + "symfony/web-profiler-bundle": "self.version", + "symfony/yaml": "self.version" + }, + "require-dev": { + "doctrine/data-fixtures": "1.0.*", + "doctrine/dbal": "~2.2", + "doctrine/orm": "~2.2,>=2.2.3", + "egulias/email-validator": "~1.2", + "ircmaxell/password-compat": "1.0.*", + "monolog/monolog": "~1.3", + "ocramius/proxy-manager": ">=0.3.1,<0.6-dev", + "propel/propel1": "1.6.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\": "src/" + }, + "classmap": [ + "src/Symfony/Component/HttpFoundation/Resources/stubs", + "src/Symfony/Component/Intl/Resources/stubs" + ], + "files": [ + "src/Symfony/Component/Intl/Resources/stubs/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "The Symfony PHP framework", + "homepage": "http://symfony.com", + "keywords": [ + "framework" + ], + "time": "2014-10-24 06:55:39" + }, + { + "name": "twig/extensions", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig-extensions.git", + "reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/8cf4b9fe04077bd54fc73f4fde83347040c3b8cd", + "reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd", + "shasum": "" + }, + "require": { + "twig/twig": "~1.12" + }, + "require-dev": { + "symfony/translation": "~2.3" + }, + "suggest": { + "symfony/translation": "Allow the time_diff output to be translated" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_Extensions_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Common additional features for Twig that do not directly belong in core", + "homepage": "http://twig.sensiolabs.org/doc/extensions/index.html", + "keywords": [ + "i18n", + "text" + ], + "time": "2014-10-30 14:30:03" + }, + { + "name": "twig/twig", + "version": "v1.16.2", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Twig.git", + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/42f758d9fe2146d1f0470604fc05ee43580873fc", + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.16-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "https://github.com/fabpot/Twig/graphs/contributors", + "role": "Contributors" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", + "keywords": [ + "templating" + ], + "time": "2014-10-17 12:53:44" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": { + "doctrine/dbal": 20, + "doctrine/orm": 20, + "doctrine/common": 20, + "doctrine/doctrine-bundle": 20 + }, + "prefer-stable": false, + "platform": [], + "platform-dev": [] +} diff --git a/console.sh b/console.sh new file mode 100755 index 000000000..609ce9cde --- /dev/null +++ b/console.sh @@ -0,0 +1 @@ +php Tests/Fixtures/App/console $1 $2 $3 $4 $5 \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 000000000..6d8da1316 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,20 @@ + + + + ./Tests + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + + + + \ No newline at end of file From 8d4ad512bdd75c520dd9f8a79dc780ec8a3b4d6f Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 16:34:09 +0100 Subject: [PATCH 004/210] Adding Report Entity --- Controller/DefaultController.php | 13 -- Controller/ReportController.php | 224 +++++++++++++++++++++++ Entity/Report.php | 221 ++++++++++++++++++++++ Form/ReportType.php | 44 +++++ Resources/config/doctrine/report.orm.yml | 25 +++ Resources/config/routing.yml | 6 +- Resources/config/routing/report.yml | 30 +++ Resources/views/Default/index.html.twig | 1 - 8 files changed, 547 insertions(+), 17 deletions(-) delete mode 100644 Controller/DefaultController.php create mode 100644 Controller/ReportController.php create mode 100644 Entity/Report.php create mode 100644 Form/ReportType.php create mode 100644 Resources/config/doctrine/report.orm.yml create mode 100644 Resources/config/routing/report.yml delete mode 100644 Resources/views/Default/index.html.twig diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php deleted file mode 100644 index bc7e4c5ec..000000000 --- a/Controller/DefaultController.php +++ /dev/null @@ -1,13 +0,0 @@ -render('ChillReportBundle:Default:index.html.twig', array('name' => $name)); - } -} diff --git a/Controller/ReportController.php b/Controller/ReportController.php new file mode 100644 index 000000000..26e0f54b9 --- /dev/null +++ b/Controller/ReportController.php @@ -0,0 +1,224 @@ +getDoctrine()->getManager(); + + $entities = $em->getRepository('ChillReportBundle:Report')->findAll(); + + return $this->render('ChillReportBundle:Report:index.html.twig', array( + 'entities' => $entities, + )); + } + /** + * Creates a new Report entity. + * + */ + public function createAction(Request $request) + { + $entity = new Report(); + $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($entity); + $em->flush(); + + return $this->redirect($this->generateUrl('report_show', array('id' => $entity->getId()))); + } + + return $this->render('ChillReportBundle:Report:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Creates a form to create a Report entity. + * + * @param Report $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createCreateForm(Report $entity) + { + $form = $this->createForm(new ReportType(), $entity, array( + 'action' => $this->generateUrl('report_create'), + 'method' => 'POST', + )); + + $form->add('submit', 'submit', array('label' => 'Create')); + + return $form; + } + + /** + * Displays a form to create a new Report entity. + * + */ + public function newAction() + { + $entity = new Report(); + $form = $this->createCreateForm($entity); + + return $this->render('ChillReportBundle:Report:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a Report entity. + * + */ + public function showAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillReportBundle:Report')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Report entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillReportBundle:Report:show.html.twig', array( + 'entity' => $entity, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing Report entity. + * + */ + public function editAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillReportBundle:Report')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Report entity.'); + } + + $editForm = $this->createEditForm($entity); + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillReportBundle:Report:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Creates a form to edit a Report entity. + * + * @param Report $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createEditForm(Report $entity) + { + $form = $this->createForm(new ReportType(), $entity, array( + 'action' => $this->generateUrl('report_update', array('id' => $entity->getId())), + 'method' => 'PUT', + )); + + $form->add('submit', 'submit', array('label' => 'Update')); + + return $form; + } + /** + * Edits an existing Report entity. + * + */ + public function updateAction(Request $request, $id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillReportBundle:Report')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Report entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + $editForm = $this->createEditForm($entity); + $editForm->handleRequest($request); + + if ($editForm->isValid()) { + $em->flush(); + + return $this->redirect($this->generateUrl('report_edit', array('id' => $id))); + } + + return $this->render('ChillReportBundle:Report:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + /** + * Deletes a Report entity. + * + */ + public function deleteAction(Request $request, $id) + { + $form = $this->createDeleteForm($id); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository('ChillReportBundle:Report')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Report entity.'); + } + + $em->remove($entity); + $em->flush(); + } + + return $this->redirect($this->generateUrl('report')); + } + + /** + * Creates a form to delete a Report entity by id. + * + * @param mixed $id The entity id + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm($id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('report_delete', array('id' => $id))) + ->setMethod('DELETE') + ->add('submit', 'submit', array('label' => 'Delete')) + ->getForm() + ; + } +} diff --git a/Entity/Report.php b/Entity/Report.php new file mode 100644 index 000000000..83b2bfb38 --- /dev/null +++ b/Entity/Report.php @@ -0,0 +1,221 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ReportBundle\Entity; + +/** + * Report + */ +class Report +{ + /** + * @var integer + */ + private $id; + + /** + * @var \User + */ + private $user; + + /** + * @var \Person + */ + private $person; + + /** + * @var \DateTime + */ + private $date; + + /** + * @var string + */ + private $scope; + + /** + * @var array + */ + private $cFData; + + /** + * @var \CustomFieldsGroup + */ + private $cFGroup; + + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set userr + * + * @param \User $user + * + * @return Report + */ + public function setUser($user) + { + $this->userr = $user; + + return $this; + } + + /** + * Get user + * + * @return \User + */ + public function getUser() + { + return $this->user; + } + + /** + * Set person + * + * @param \Person $person + * + * @return Report + */ + public function setPerson($person) + { + $this->person = $person; + + return $this; + } + + /** + * Get person + * + * @return \Person + */ + public function getPerson() + { + return $this->person; + } + + /** + * Set date + * + * @param \DateTime $date + * + * @return Report + */ + public function setDate($date) + { + $this->date = $date; + + return $this; + } + + /** + * Get date + * + * @return \DateTime + */ + public function getDate() + { + return $this->date; + } + + /** + * Set scope + * + * @param string $scope + * + * @return Report + */ + public function setScope($scope) + { + $this->scope = $scope; + + return $this; + } + + /** + * Get scope + * + * @return string + */ + public function getScope() + { + return $this->scope; + } + + /** + * Set cFData + * + * @param array $cFData + * + * @return Report + */ + public function setCFData($cFData) + { + $this->cFData = $cFData; + + return $this; + } + + /** + * Get cFData + * + * @return array + */ + public function getCFData() + { + return $this->cFData; + } + + /** + * Set cFGroup + * + * @param \CustomFieldsGroup $cFGroup + * + * @return Report + */ + public function setCFGroup($cFGroup) + { + $this->cFGroup = $cFGroup; + + return $this; + } + + /** + * Get cFGroup + * + * @return \CustomFieldsGroup + */ + public function getCFGroup() + { + return $this->cFGroup; + } +} \ No newline at end of file diff --git a/Form/ReportType.php b/Form/ReportType.php new file mode 100644 index 000000000..566b8201e --- /dev/null +++ b/Form/ReportType.php @@ -0,0 +1,44 @@ +add('user') + ->add('person') + ->add('date') + ->add('scope') + ->add('cFData') + ->add('cFGroup') + ; + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Chill\ReportBundle\Entity\Report' + )); + } + + /** + * @return string + */ + public function getName() + { + return 'chill_reportbundle_report'; + } +} diff --git a/Resources/config/doctrine/report.orm.yml b/Resources/config/doctrine/report.orm.yml new file mode 100644 index 000000000..49a6182c5 --- /dev/null +++ b/Resources/config/doctrine/report.orm.yml @@ -0,0 +1,25 @@ +Chill\ReportBundle\Entity\Report: + type: entity + table: null + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + date: + type: datetime + scope: + type: string + length: 255 + cFData: + type: json_array + manyToOne: + user: + targetEntity: Chill\MainBundle\Entity\User + person: + targetEntity: Chill\MainBundle\Entity\Person + cFGroup: + targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldsGroup + lifecycleCallbacks: { } \ No newline at end of file diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index b2452ae9a..e9f83604e 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,3 +1,3 @@ -chill_report_homepage: - path: /hello/{name} - defaults: { _controller: ChillReportBundle:Default:index } +cl_custom_fields_report: + resource: "@ChillReportBundle/Resources/config/routing/report.yml" + prefix: /report \ No newline at end of file diff --git a/Resources/config/routing/report.yml b/Resources/config/routing/report.yml new file mode 100644 index 000000000..7f600f680 --- /dev/null +++ b/Resources/config/routing/report.yml @@ -0,0 +1,30 @@ +report: + path: / + defaults: { _controller: "ChillReportBundle:report:index" } + +report_show: + path: /{id}/show + defaults: { _controller: "ChillReportBundle:report:show" } + +report_new: + path: /new + defaults: { _controller: "ChillReportBundle:report:new" } + +report_create: + path: /create + defaults: { _controller: "ChillReportBundle:report:create" } + requirements: { _method: post } + +report_edit: + path: /{id}/edit + defaults: { _controller: "ChillReportBundle:report:edit" } + +report_update: + path: /{id}/update + defaults: { _controller: "ChillReportBundle:report:update" } + requirements: { _method: post|put } + +report_delete: + path: /{id}/delete + defaults: { _controller: "ChillReportBundle:report:delete" } + requirements: { _method: post|delete } diff --git a/Resources/views/Default/index.html.twig b/Resources/views/Default/index.html.twig deleted file mode 100644 index 4ce626e9b..000000000 --- a/Resources/views/Default/index.html.twig +++ /dev/null @@ -1 +0,0 @@ -Hello {{ name }}! From ec8ec6d6dfb54fea108f6d388947442d1c81de41 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 17:30:28 +0100 Subject: [PATCH 005/210] Debug --- Resources/config/doctrine/{report.orm.yml => Report.orm.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Resources/config/doctrine/{report.orm.yml => Report.orm.yml} (100%) diff --git a/Resources/config/doctrine/report.orm.yml b/Resources/config/doctrine/Report.orm.yml similarity index 100% rename from Resources/config/doctrine/report.orm.yml rename to Resources/config/doctrine/Report.orm.yml From cfa5dfcf5f20aa07c3c3cd206b751fb8cf3a8998 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 17:30:48 +0100 Subject: [PATCH 006/210] Debug --- Resources/config/doctrine/Report.orm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/doctrine/Report.orm.yml b/Resources/config/doctrine/Report.orm.yml index 49a6182c5..5ae4cf3f9 100644 --- a/Resources/config/doctrine/Report.orm.yml +++ b/Resources/config/doctrine/Report.orm.yml @@ -19,7 +19,7 @@ Chill\ReportBundle\Entity\Report: user: targetEntity: Chill\MainBundle\Entity\User person: - targetEntity: Chill\MainBundle\Entity\Person + targetEntity: Chill\PersonBundle\Entity\Person cFGroup: targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldsGroup lifecycleCallbacks: { } \ No newline at end of file From acac358503e0adcf50c9f2eedd251cd49b2f658b Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 17:33:01 +0100 Subject: [PATCH 007/210] Adding routing for Report --- Resources/config/services.yml | 5 ++++ Routing/RoutesLoader.php | 51 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 Routing/RoutesLoader.php diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 73a6dafca..03a3cb0d6 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -2,3 +2,8 @@ services: # chill_report.example: # class: Chill\ReportBundle\Example # arguments: [@service_id, "plain_value", %parameter%] +services: + chill.report.routing_loader: + class: Chill\ReportBundle\Routing\RoutesLoader + tags: + - { name: routing.loader } \ No newline at end of file diff --git a/Routing/RoutesLoader.php b/Routing/RoutesLoader.php new file mode 100644 index 000000000..ce234aa16 --- /dev/null +++ b/Routing/RoutesLoader.php @@ -0,0 +1,51 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ReportBundle\Routing; + +use Symfony\Component\Config\Loader\Loader; +use Symfony\Component\Routing\RouteCollection; + +/** + * Load routes automatically + * + * @author Champs-Libres + */ +class RoutesLoader extends Loader +{ + public function load($resource, $type = null) + { + $collection = new RouteCollection(); + + $resource = '@ChillReportBundle/Resources/config/routing.yml'; + $type = 'yaml'; + + $importedRoutes = $this->import($resource, $type); + + $collection->addCollection($importedRoutes); + + return $collection; + } + + public function supports($resource, $type = null) + { + return 'chill_routes_report' === $type; + } +} From c4ee2c45fa4e3823cddcd42127289b371ba62f14 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 17:45:17 +0100 Subject: [PATCH 008/210] debug --- Resources/config/routing/report.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Resources/config/routing/report.yml b/Resources/config/routing/report.yml index 7f600f680..bb21c22c0 100644 --- a/Resources/config/routing/report.yml +++ b/Resources/config/routing/report.yml @@ -1,30 +1,30 @@ report: path: / - defaults: { _controller: "ChillReportBundle:report:index" } + defaults: { _controller: "ChillReportBundle:Report:index" } report_show: path: /{id}/show - defaults: { _controller: "ChillReportBundle:report:show" } + defaults: { _controller: "ChillReportBundle:Report:show" } report_new: path: /new - defaults: { _controller: "ChillReportBundle:report:new" } + defaults: { _controller: "ChillReportBundle:Report:new" } report_create: path: /create - defaults: { _controller: "ChillReportBundle:report:create" } + defaults: { _controller: "ChillReportBundle:Report:create" } requirements: { _method: post } report_edit: path: /{id}/edit - defaults: { _controller: "ChillReportBundle:report:edit" } + defaults: { _controller: "ChillReportBundle:Report:edit" } report_update: path: /{id}/update - defaults: { _controller: "ChillReportBundle:report:update" } + defaults: { _controller: "ChillReportBundle:Report:update" } requirements: { _method: post|put } report_delete: path: /{id}/delete - defaults: { _controller: "ChillReportBundle:report:delete" } + defaults: { _controller: "ChillReportBundle:Report:delete" } requirements: { _method: post|delete } From 5fff168c87b58304ed2e6410193b51eae472206a Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 17:45:29 +0100 Subject: [PATCH 009/210] Adding views --- Resources/views/Report/edit.html.twig | 16 ++++++++ Resources/views/Report/index.html.twig | 51 +++++++++++++++++++++++++ Resources/views/Report/new.html.twig | 15 ++++++++ Resources/views/Report/show.html.twig | 52 ++++++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 Resources/views/Report/edit.html.twig create mode 100644 Resources/views/Report/index.html.twig create mode 100644 Resources/views/Report/new.html.twig create mode 100644 Resources/views/Report/show.html.twig diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig new file mode 100644 index 000000000..407ec3a55 --- /dev/null +++ b/Resources/views/Report/edit.html.twig @@ -0,0 +1,16 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Report edit

+ + {{ form(edit_form) }} + + +{% endblock %} diff --git a/Resources/views/Report/index.html.twig b/Resources/views/Report/index.html.twig new file mode 100644 index 000000000..7cc7549f1 --- /dev/null +++ b/Resources/views/Report/index.html.twig @@ -0,0 +1,51 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Report list

+ + + + + + + + + + + + + + + + {% for entity in entities %} + + + + + + + + + + + {% endfor %} + +
IdUserrPersonDateScopeCfdataCfgroupActions
{{ entity.id }}{{ entity.userr }}{{ entity.person }}{% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif %}{{ entity.scope }}{{ entity.cFData }}{{ entity.cFGroup }} + +
+ + + {% endblock %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig new file mode 100644 index 000000000..dfe5f4320 --- /dev/null +++ b/Resources/views/Report/new.html.twig @@ -0,0 +1,15 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Report creation

+ + {{ form(form) }} + + +{% endblock %} diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/show.html.twig new file mode 100644 index 000000000..064b13b7a --- /dev/null +++ b/Resources/views/Report/show.html.twig @@ -0,0 +1,52 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Report

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ entity.id }}
Userr{{ entity.userr }}
Person{{ entity.person }}
Date{{ entity.date|date('Y-m-d H:i:s') }}
Scope{{ entity.scope }}
Cfdata{{ entity.cFData }}
Cfgroup{{ entity.cFGroup }}
+ + +{% endblock %} \ No newline at end of file From 8a7b6d4055e16f43e184f1d223c7af03cbaded0d Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 19:03:23 +0100 Subject: [PATCH 010/210] declareReportAsCustomizable --- DependencyInjection/ChillReportExtension.php | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index 7e3506b5b..972772a23 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -6,13 +6,14 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader; +use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; /** * This is the class that loads and manages your bundle configuration * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} */ -class ChillReportExtension extends Extension +class ChillReportExtension extends Extension implements PrependExtensionInterface { /** * {@inheritdoc} @@ -25,4 +26,24 @@ class ChillReportExtension extends Extension $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); } + + /** + * Declare the entity Report, as a customizable entity (can add custom fields) + */ + public function declareReportAsCustomizable(ContainerBuilder $container) + { + $bundles = $container->getParameter('kernel.bundles'); + if (!isset($bundles['ChillCustomFieldsBundle'])) { + throw new MissingBundleException('ChillCustomFieldsBundle'); + } + + $customizables_entities['customizables_entities'][] = array('class' => 'Chill\ReportBundle\Entity\Report', 'name' => 'ReportName'); + + $container->prependExtensionConfig('chill_custom_fields', $customizables_entities); + } + + public function prepend(ContainerBuilder $container) + { + $this->declareReportAsCustomizable($container); + } } From f1b66bb6dc52afda395c5930e176740dadeb3949 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 19:16:03 +0100 Subject: [PATCH 011/210] Refactoring --- DependencyInjection/ChillReportExtension.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index 972772a23..98bd59c98 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -37,9 +37,13 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac throw new MissingBundleException('ChillCustomFieldsBundle'); } - $customizables_entities['customizables_entities'][] = array('class' => 'Chill\ReportBundle\Entity\Report', 'name' => 'ReportName'); - - $container->prependExtensionConfig('chill_custom_fields', $customizables_entities); + $container->prependExtensionConfig('chill_custom_fields', + array('customizables_entities' => + array( + array('class' => 'Chill\ReportBundle\Entity\Report', 'name' => 'ReportEntity') + ) + ) + ); } public function prepend(ContainerBuilder $container) From c7e4388645cc117833aa6813f8eecbdf9b6dcbd2 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 23:17:54 +0100 Subject: [PATCH 012/210] Phpunit is working --- DependencyInjection/ChillReportExtension.php | 1 + Tests/Controller/DefaultControllerTest.php | 17 ----------------- Tests/Fixtures/App/AppKernel.php | 2 ++ Tests/Fixtures/App/config/config.yml | 19 +++++++++++++++++-- Tests/Fixtures/App/config/parameters.yml | 6 ++++++ Tests/Fixtures/App/config/parameters.yml.dist | 6 ++++++ Tests/Fixtures/App/config/routing.yml | 1 - composer.json | 6 +++++- 8 files changed, 37 insertions(+), 21 deletions(-) delete mode 100644 Tests/Controller/DefaultControllerTest.php create mode 100644 Tests/Fixtures/App/config/parameters.yml create mode 100644 Tests/Fixtures/App/config/parameters.yml.dist diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index 98bd59c98..e0b7406f1 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -7,6 +7,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; +use Chill\MainBundle\DependencyInjection\MissingBundleException; /** * This is the class that loads and manages your bundle configuration diff --git a/Tests/Controller/DefaultControllerTest.php b/Tests/Controller/DefaultControllerTest.php deleted file mode 100644 index 3ab2fb41c..000000000 --- a/Tests/Controller/DefaultControllerTest.php +++ /dev/null @@ -1,17 +0,0 @@ -request('GET', '/hello/Fabien'); - - $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0); - } -} diff --git a/Tests/Fixtures/App/AppKernel.php b/Tests/Fixtures/App/AppKernel.php index 4874b2330..20f9a4bd5 100644 --- a/Tests/Fixtures/App/AppKernel.php +++ b/Tests/Fixtures/App/AppKernel.php @@ -11,6 +11,8 @@ class AppKernel extends Kernel new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Chill\ReportBundle\ChillReportBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), + new Chill\CustomFieldsBundle\ChillCustomFieldsBundle(), + new Doctrine\Bundle\DoctrineBundle\DoctrineBundle() ); } diff --git a/Tests/Fixtures/App/config/config.yml b/Tests/Fixtures/App/config/config.yml index e0b6e919f..49bf26edf 100644 --- a/Tests/Fixtures/App/config/config.yml +++ b/Tests/Fixtures/App/config/config.yml @@ -1,4 +1,6 @@ -# config/config.yml +imports: + - { resource: parameters.yml } + framework: secret: Not very secret router: { resource: "%kernel.root_dir%/config/routing.yml" } @@ -9,4 +11,17 @@ framework: translator: { fallback: fr } profiler: { only_exceptions: false } templating: #required for assetic. Remove if not needed - engines: ['twig'] \ No newline at end of file + engines: ['twig'] + +doctrine: + dbal: + driver: pdo_pgsql + host: "%database_host%" + port: "%database_port%" + dbname: "%database_name%" + user: "%database_user%" + password: "%database_password%" + charset: UTF8 + orm: + auto_generate_proxy_classes: "%kernel.debug%" + auto_mapping: true \ No newline at end of file diff --git a/Tests/Fixtures/App/config/parameters.yml b/Tests/Fixtures/App/config/parameters.yml new file mode 100644 index 000000000..fa3e55dae --- /dev/null +++ b/Tests/Fixtures/App/config/parameters.yml @@ -0,0 +1,6 @@ +parameters: + database_host: 127.0.0.1 + database_port: 5434 + database_name: symfony + database_user: symfony + database_password: symfony \ No newline at end of file diff --git a/Tests/Fixtures/App/config/parameters.yml.dist b/Tests/Fixtures/App/config/parameters.yml.dist new file mode 100644 index 000000000..fa3e55dae --- /dev/null +++ b/Tests/Fixtures/App/config/parameters.yml.dist @@ -0,0 +1,6 @@ +parameters: + database_host: 127.0.0.1 + database_port: 5434 + database_name: symfony + database_user: symfony + database_password: symfony \ No newline at end of file diff --git a/Tests/Fixtures/App/config/routing.yml b/Tests/Fixtures/App/config/routing.yml index e525ae9d4..e69de29bb 100644 --- a/Tests/Fixtures/App/config/routing.yml +++ b/Tests/Fixtures/App/config/routing.yml @@ -1 +0,0 @@ -routing.yml \ No newline at end of file diff --git a/composer.json b/composer.json index 819cdd1ce..f4ccd8fd4 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,10 @@ "doctrine/dbal": "2.5.*@dev", "doctrine/orm": "2.5.*@dev", "doctrine/common": "2.4.*@dev", - "doctrine/doctrine-bundle": "~1.2@dev" + "doctrine/doctrine-bundle": "~1.2@dev", + "chill-project/main": "dev-master", + "chill-project/custom-fields": "dev-master" + }, + "require-dev": { } } From 2e89acfcb681e4766360eabf44f851aaf6bc3bcb Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 23:22:50 +0100 Subject: [PATCH 013/210] removeing compoer.log from gitignore --- .gitignore | 1 + composer.lock | 1363 ------------------------------------------------- 2 files changed, 1 insertion(+), 1363 deletions(-) delete mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 57872d0f1..55940e57c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /vendor/ +composer.lock \ No newline at end of file diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 485aeffb6..000000000 --- a/composer.lock +++ /dev/null @@ -1,1363 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "d9e57814e57c031367dcf5d74ab98094", - "packages": [ - { - "name": "doctrine/annotations", - "version": "v1.2.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/6a6bec0670bb6e71a263b08bc1b98ea242928633", - "reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633", - "shasum": "" - }, - "require": { - "doctrine/lexer": "1.*", - "php": ">=5.3.2" - }, - "require-dev": { - "doctrine/cache": "1.*", - "phpunit/phpunit": "4.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Annotations\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "time": "2014-09-25 16:45:30" - }, - { - "name": "doctrine/cache", - "version": "v1.3.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/cache.git", - "reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/cf483685798a72c93bf4206e3dd6358ea07d64e7", - "reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "conflict": { - "doctrine/common": ">2.2,<2.4" - }, - "require-dev": { - "phpunit/phpunit": ">=3.7", - "satooshi/php-coveralls": "~0.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Cache\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Caching library offering an object-oriented API for many cache backends", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "cache", - "caching" - ], - "time": "2014-09-17 14:24:04" - }, - { - "name": "doctrine/collections", - "version": "v1.2", - "source": { - "type": "git", - "url": "https://github.com/doctrine/collections.git", - "reference": "b99c5c46c87126201899afe88ec490a25eedd6a2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/b99c5c46c87126201899afe88ec490a25eedd6a2", - "reference": "b99c5c46c87126201899afe88ec490a25eedd6a2", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Collections\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/", - "role": "Creator" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "Collections Abstraction library", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "array", - "collections", - "iterator" - ], - "time": "2014-02-03 23:07:43" - }, - { - "name": "doctrine/common", - "version": "2.4.x-dev", - "source": { - "type": "git", - "url": "https://github.com/doctrine/common.git", - "reference": "ae92d076442e27b6910dd86a1292a8867cf5cfe4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/ae92d076442e27b6910dd86a1292a8867cf5cfe4", - "reference": "ae92d076442e27b6910dd86a1292a8867cf5cfe4", - "shasum": "" - }, - "require": { - "doctrine/annotations": "1.*", - "doctrine/cache": "1.*", - "doctrine/collections": "1.*", - "doctrine/inflector": "1.*", - "doctrine/lexer": "1.*", - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "~3.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/", - "role": "Creator" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "Common Library for Doctrine projects", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "collections", - "eventmanager", - "persistence", - "spl" - ], - "time": "2014-05-21 19:29:23" - }, - { - "name": "doctrine/dbal", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/doctrine/dbal.git", - "reference": "ec6da750f9d3ee83f26fe921a9c57fdda73f07a0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/ec6da750f9d3ee83f26fe921a9c57fdda73f07a0", - "reference": "ec6da750f9d3ee83f26fe921a9c57fdda73f07a0", - "shasum": "" - }, - "require": { - "doctrine/common": ">=2.4,<2.6-dev", - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "4.*", - "symfony/console": "2.*" - }, - "suggest": { - "symfony/console": "For helpful console commands such as SQL execution and import of files." - }, - "bin": [ - "bin/doctrine-dbal" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\DBAL\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - } - ], - "description": "Database Abstraction Layer", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "database", - "dbal", - "persistence", - "queryobject" - ], - "time": "2014-11-07 10:05:10" - }, - { - "name": "doctrine/doctrine-bundle", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/doctrine/DoctrineBundle.git", - "reference": "d9763ccbb637958133c42bdcc3d31c5a6821b9e2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/d9763ccbb637958133c42bdcc3d31c5a6821b9e2", - "reference": "d9763ccbb637958133c42bdcc3d31c5a6821b9e2", - "shasum": "" - }, - "require": { - "doctrine/dbal": "~2.3", - "doctrine/doctrine-cache-bundle": "~1.0", - "jdorn/sql-formatter": "~1.1", - "php": ">=5.3.2", - "symfony/doctrine-bridge": "~2.2", - "symfony/framework-bundle": "~2.2" - }, - "require-dev": { - "doctrine/orm": "~2.3", - "phpunit/php-code-coverage": "~1.2", - "phpunit/phpunit": "~3.7", - "phpunit/phpunit-mock-objects": "~1.2", - "satooshi/php-coveralls": "~0.6.1", - "symfony/validator": "~2.2", - "symfony/yaml": "~2.2", - "twig/twig": "~1" - }, - "suggest": { - "doctrine/orm": "The Doctrine ORM integration is optional in the bundle.", - "symfony/web-profiler-bundle": "to use the data collector" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Bundle\\DoctrineBundle\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Doctrine Project", - "homepage": "http://www.doctrine-project.org/" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony DoctrineBundle", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "database", - "dbal", - "orm", - "persistence" - ], - "time": "2014-10-04 16:13:24" - }, - { - "name": "doctrine/doctrine-cache-bundle", - "version": "1.0.0", - "target-dir": "Doctrine/Bundle/DoctrineCacheBundle", - "source": { - "type": "git", - "url": "https://github.com/doctrine/DoctrineCacheBundle.git", - "reference": "49a9d2d9a35863201e5e608d1194db28946c4552" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/DoctrineCacheBundle/zipball/49a9d2d9a35863201e5e608d1194db28946c4552", - "reference": "49a9d2d9a35863201e5e608d1194db28946c4552", - "shasum": "" - }, - "require": { - "doctrine/cache": "~1.3", - "doctrine/inflector": "~1.0", - "php": ">=5.3.2", - "symfony/doctrine-bridge": "~2.2", - "symfony/framework-bundle": "~2.2", - "symfony/security": "~2.2" - }, - "require-dev": { - "instaclick/coding-standard": "~1.1", - "instaclick/object-calisthenics-sniffs": "dev-master", - "instaclick/symfony2-coding-standard": "dev-remaster", - "phpunit/phpunit": "~3.7", - "satooshi/php-coveralls": "~0.6.1", - "squizlabs/php_codesniffer": "dev-master", - "symfony/validator": "~2.2", - "symfony/yaml": "~2.2" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Bundle\\DoctrineCacheBundle": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Fabio B. Silva", - "email": "fabio.bat.silva@gmail.com" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@hotmail.com" - }, - { - "name": "Doctrine Project", - "homepage": "http://www.doctrine-project.org/" - } - ], - "description": "Symfony2 Bundle for Doctrine Cache", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "cache", - "caching" - ], - "time": "2014-03-04 19:18:55" - }, - { - "name": "doctrine/inflector", - "version": "v1.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/inflector.git", - "reference": "54b8333d2a5682afdc690060c1cf384ba9f47f08" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/54b8333d2a5682afdc690060c1cf384ba9f47f08", - "reference": "54b8333d2a5682afdc690060c1cf384ba9f47f08", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "autoload": { - "psr-0": { - "Doctrine\\Common\\Inflector\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/", - "role": "Creator" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "Common String Manipulations with regard to casing and singular/plural rules.", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "inflection", - "pluarlize", - "singuarlize", - "string" - ], - "time": "2013-01-10 21:49:15" - }, - { - "name": "doctrine/instantiator", - "version": "1.0.4", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "2.0.*@ALPHA" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Instantiator\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2014-10-13 12:58:55" - }, - { - "name": "doctrine/lexer", - "version": "v1.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/2f708a85bb3aab5d99dab8be435abd73e0b18acb", - "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "autoload": { - "psr-0": { - "Doctrine\\Common\\Lexer\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "lexer", - "parser" - ], - "time": "2013-01-12 18:59:04" - }, - { - "name": "doctrine/orm", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/doctrine/doctrine2.git", - "reference": "76e1a469ef3c4af4ef9d60c769822d4283809217" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/76e1a469ef3c4af4ef9d60c769822d4283809217", - "reference": "76e1a469ef3c4af4ef9d60c769822d4283809217", - "shasum": "" - }, - "require": { - "doctrine/collections": "~1.2", - "doctrine/dbal": ">=2.5-dev,<2.6-dev", - "doctrine/instantiator": "~1.0.1", - "ext-pdo": "*", - "php": ">=5.3.2", - "symfony/console": "~2.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "dev-master", - "symfony/yaml": "~2.1" - }, - "suggest": { - "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" - }, - "bin": [ - "bin/doctrine", - "bin/doctrine.php" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\ORM\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - } - ], - "description": "Object-Relational-Mapper for PHP", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "database", - "orm" - ], - "time": "2014-11-05 12:19:29" - }, - { - "name": "jdorn/sql-formatter", - "version": "v1.2.17", - "source": { - "type": "git", - "url": "https://github.com/jdorn/sql-formatter.git", - "reference": "64990d96e0959dff8e059dfcdc1af130728d92bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jdorn/sql-formatter/zipball/64990d96e0959dff8e059dfcdc1af130728d92bc", - "reference": "64990d96e0959dff8e059dfcdc1af130728d92bc", - "shasum": "" - }, - "require": { - "php": ">=5.2.4" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "lib" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jeremy Dorn", - "email": "jeremy@jeremydorn.com", - "homepage": "http://jeremydorn.com/" - } - ], - "description": "a PHP SQL highlighting library", - "homepage": "https://github.com/jdorn/sql-formatter/", - "keywords": [ - "highlight", - "sql" - ], - "time": "2014-01-12 16:20:24" - }, - { - "name": "kriswallsmith/assetic", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/kriswallsmith/assetic.git", - "reference": "df991c124a2212371443b586a1be767500036dee" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/df991c124a2212371443b586a1be767500036dee", - "reference": "df991c124a2212371443b586a1be767500036dee", - "shasum": "" - }, - "require": { - "php": ">=5.3.1", - "symfony/process": "~2.1" - }, - "require-dev": { - "cssmin/cssmin": "*", - "joliclic/javascript-packer": "*", - "kamicane/packager": "*", - "leafo/lessphp": "*", - "leafo/scssphp": "*", - "leafo/scssphp-compass": "*", - "mrclay/minify": "*", - "patchwork/jsqueeze": "~1.0", - "phpunit/phpunit": "~4", - "psr/log": "~1.0", - "ptachoire/cssembed": "*", - "twig/twig": "~1.6" - }, - "suggest": { - "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", - "leafo/scssphp": "Assetic provides the integration with the scssphp SCSS compiler", - "leafo/scssphp-compass": "Assetic provides the integration with the SCSS compass plugin", - "patchwork/jsqueeze": "Assetic provides the integration with the JSqueeze JavaScript compressor", - "ptachoire/cssembed": "Assetic provides the integration with phpcssembed to embed data uris", - "twig/twig": "Assetic provides the integration with the Twig templating engine" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-0": { - "Assetic": "src/" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kris Wallsmith", - "email": "kris.wallsmith@gmail.com", - "homepage": "http://kriswallsmith.net/" - } - ], - "description": "Asset Management for PHP", - "homepage": "https://github.com/kriswallsmith/assetic", - "keywords": [ - "assets", - "compression", - "minification" - ], - "time": "2014-10-14 14:45:32" - }, - { - "name": "monolog/monolog", - "version": "1.11.0", - "source": { - "type": "git", - "url": "https://github.com/Seldaek/monolog.git", - "reference": "ec3961874c43840e96da3a8a1ed20d8c73d7e5aa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/ec3961874c43840e96da3a8a1ed20d8c73d7e5aa", - "reference": "ec3961874c43840e96da3a8a1ed20d8c73d7e5aa", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/log": "~1.0" - }, - "provide": { - "psr/log-implementation": "1.0.0" - }, - "require-dev": { - "aws/aws-sdk-php": "~2.4, >2.4.8", - "doctrine/couchdb": "~1.0@dev", - "graylog2/gelf-php": "~1.0", - "phpunit/phpunit": "~3.7.0", - "raven/raven": "~0.5", - "ruflin/elastica": "0.90.*", - "videlalvaro/php-amqplib": "~2.4" - }, - "suggest": { - "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", - "doctrine/couchdb": "Allow sending log messages to a CouchDB server", - "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", - "ext-mongo": "Allow sending log messages to a MongoDB server", - "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", - "raven/raven": "Allow sending log messages to a Sentry server", - "rollbar/rollbar": "Allow sending log messages to Rollbar", - "ruflin/elastica": "Allow sending log messages to an Elastic Search server", - "videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11.x-dev" - } - }, - "autoload": { - "psr-4": { - "Monolog\\": "src/Monolog" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "Sends your logs to files, sockets, inboxes, databases and various web services", - "homepage": "http://github.com/Seldaek/monolog", - "keywords": [ - "log", - "logging", - "psr-3" - ], - "time": "2014-09-30 13:30:58" - }, - { - "name": "psr/log", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", - "shasum": "" - }, - "type": "library", - "autoload": { - "psr-0": { - "Psr\\Log\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2012-12-21 11:40:51" - }, - { - "name": "symfony/assetic-bundle", - "version": "v2.5.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/AsseticBundle.git", - "reference": "90ea7fb66d6d5245fd4afc16e4c8070214254fec" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/AsseticBundle/zipball/90ea7fb66d6d5245fd4afc16e4c8070214254fec", - "reference": "90ea7fb66d6d5245fd4afc16e4c8070214254fec", - "shasum": "" - }, - "require": { - "kriswallsmith/assetic": "~1.2", - "php": ">=5.3.0", - "symfony/console": "~2.1", - "symfony/framework-bundle": "~2.1", - "symfony/yaml": "~2.1" - }, - "require-dev": { - "kriswallsmith/spork": "~0.2", - "patchwork/jsqueeze": "~1.0", - "symfony/class-loader": "~2.1", - "symfony/css-selector": "~2.1", - "symfony/dom-crawler": "~2.1", - "symfony/twig-bundle": "~2.1" - }, - "suggest": { - "kriswallsmith/spork": "to be able to dump assets in parallel", - "symfony/twig-bundle": "to use the Twig integration" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bundle\\AsseticBundle\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kris Wallsmith", - "email": "kris.wallsmith@gmail.com", - "homepage": "http://kriswallsmith.net/" - } - ], - "description": "Integrates Assetic into Symfony2", - "homepage": "https://github.com/symfony/AsseticBundle", - "keywords": [ - "assets", - "compression", - "minification" - ], - "time": "2014-10-15 12:03:38" - }, - { - "name": "symfony/monolog-bundle", - "version": "v2.6.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/MonologBundle.git", - "reference": "227bbeefe30f2d95e3fe5fbd1ccda414287a957a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/MonologBundle/zipball/227bbeefe30f2d95e3fe5fbd1ccda414287a957a", - "reference": "227bbeefe30f2d95e3fe5fbd1ccda414287a957a", - "shasum": "" - }, - "require": { - "monolog/monolog": "~1.8", - "php": ">=5.3.2", - "symfony/config": "~2.3", - "symfony/dependency-injection": "~2.3", - "symfony/http-kernel": "~2.3", - "symfony/monolog-bridge": "~2.3" - }, - "require-dev": { - "symfony/console": "~2.3", - "symfony/yaml": "~2.3" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "2.6.x-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bundle\\MonologBundle\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony MonologBundle", - "homepage": "http://symfony.com", - "keywords": [ - "log", - "logging" - ], - "time": "2014-07-21 00:36:06" - }, - { - "name": "symfony/symfony", - "version": "v2.5.6", - "source": { - "type": "git", - "url": "https://github.com/symfony/symfony.git", - "reference": "1a1b1e528935f15dd76169f8b1dc3ef97f0d6210" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/symfony/zipball/1a1b1e528935f15dd76169f8b1dc3ef97f0d6210", - "reference": "1a1b1e528935f15dd76169f8b1dc3ef97f0d6210", - "shasum": "" - }, - "require": { - "doctrine/common": "~2.2", - "php": ">=5.3.3", - "psr/log": "~1.0", - "twig/twig": "~1.12" - }, - "replace": { - "symfony/browser-kit": "self.version", - "symfony/class-loader": "self.version", - "symfony/config": "self.version", - "symfony/console": "self.version", - "symfony/css-selector": "self.version", - "symfony/debug": "self.version", - "symfony/dependency-injection": "self.version", - "symfony/doctrine-bridge": "self.version", - "symfony/dom-crawler": "self.version", - "symfony/event-dispatcher": "self.version", - "symfony/expression-language": "self.version", - "symfony/filesystem": "self.version", - "symfony/finder": "self.version", - "symfony/form": "self.version", - "symfony/framework-bundle": "self.version", - "symfony/http-foundation": "self.version", - "symfony/http-kernel": "self.version", - "symfony/intl": "self.version", - "symfony/locale": "self.version", - "symfony/monolog-bridge": "self.version", - "symfony/options-resolver": "self.version", - "symfony/process": "self.version", - "symfony/propel1-bridge": "self.version", - "symfony/property-access": "self.version", - "symfony/proxy-manager-bridge": "self.version", - "symfony/routing": "self.version", - "symfony/security": "self.version", - "symfony/security-acl": "self.version", - "symfony/security-bundle": "self.version", - "symfony/security-core": "self.version", - "symfony/security-csrf": "self.version", - "symfony/security-http": "self.version", - "symfony/serializer": "self.version", - "symfony/stopwatch": "self.version", - "symfony/swiftmailer-bridge": "self.version", - "symfony/templating": "self.version", - "symfony/translation": "self.version", - "symfony/twig-bridge": "self.version", - "symfony/twig-bundle": "self.version", - "symfony/validator": "self.version", - "symfony/web-profiler-bundle": "self.version", - "symfony/yaml": "self.version" - }, - "require-dev": { - "doctrine/data-fixtures": "1.0.*", - "doctrine/dbal": "~2.2", - "doctrine/orm": "~2.2,>=2.2.3", - "egulias/email-validator": "~1.2", - "ircmaxell/password-compat": "1.0.*", - "monolog/monolog": "~1.3", - "ocramius/proxy-manager": ">=0.3.1,<0.6-dev", - "propel/propel1": "1.6.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\": "src/" - }, - "classmap": [ - "src/Symfony/Component/HttpFoundation/Resources/stubs", - "src/Symfony/Component/Intl/Resources/stubs" - ], - "files": [ - "src/Symfony/Component/Intl/Resources/stubs/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "The Symfony PHP framework", - "homepage": "http://symfony.com", - "keywords": [ - "framework" - ], - "time": "2014-10-24 06:55:39" - }, - { - "name": "twig/extensions", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig-extensions.git", - "reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/8cf4b9fe04077bd54fc73f4fde83347040c3b8cd", - "reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd", - "shasum": "" - }, - "require": { - "twig/twig": "~1.12" - }, - "require-dev": { - "symfony/translation": "~2.3" - }, - "suggest": { - "symfony/translation": "Allow the time_diff output to be translated" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_Extensions_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Common additional features for Twig that do not directly belong in core", - "homepage": "http://twig.sensiolabs.org/doc/extensions/index.html", - "keywords": [ - "i18n", - "text" - ], - "time": "2014-10-30 14:30:03" - }, - { - "name": "twig/twig", - "version": "v1.16.2", - "source": { - "type": "git", - "url": "https://github.com/fabpot/Twig.git", - "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/42f758d9fe2146d1f0470604fc05ee43580873fc", - "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc", - "shasum": "" - }, - "require": { - "php": ">=5.2.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.16-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, - { - "name": "Twig Team", - "homepage": "https://github.com/fabpot/Twig/graphs/contributors", - "role": "Contributors" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", - "keywords": [ - "templating" - ], - "time": "2014-10-17 12:53:44" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "doctrine/dbal": 20, - "doctrine/orm": 20, - "doctrine/common": 20, - "doctrine/doctrine-bundle": 20 - }, - "prefer-stable": false, - "platform": [], - "platform-dev": [] -} From 005e56c72aaaaf1732470f06a9609a9d7504e1a2 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 23:52:46 +0100 Subject: [PATCH 014/210] Test : Check if class Chill\ReportBundle\Entity\Report is in chill_custom_fields.customizables_entities --- .../ChillReportExtensionTest.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Tests/DependencyInjection/ChillReportExtensionTest.php diff --git a/Tests/DependencyInjection/ChillReportExtensionTest.php b/Tests/DependencyInjection/ChillReportExtensionTest.php new file mode 100644 index 000000000..beb246ea0 --- /dev/null +++ b/Tests/DependencyInjection/ChillReportExtensionTest.php @@ -0,0 +1,29 @@ + 'test')); + $customizablesEntities = static::$kernel->getContainer() + ->getParameter('chill_custom_fields.customizables_entities'); + + $reportFounded = false; + foreach ($customizablesEntities as $customizablesEntity) { + if($customizablesEntity['class'] === 'Chill\ReportBundle\Entity\Report') { + $reportFounded = true; + } + } + + if(! $reportFounded) { + throw new Exception("Class Chill\ReportBundle\Entity\Report not found in chill_custom_fields.customizables_entities", 1); + } + } +} From 1ea54c39b32975c2769f9e8d47bd6474d337b4df Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sat, 8 Nov 2014 16:59:36 +0100 Subject: [PATCH 015/210] Choice of the Form --- Controller/ReportController.php | 24 +++++++++++++++++++++++- Resources/views/Report/index.html.twig | 16 ++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 26e0f54b9..2e3b068ef 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -19,16 +19,38 @@ class ReportController extends Controller * Lists all Report entities. * */ - public function indexAction() + public function indexAction(Request $request) { $em = $this->getDoctrine()->getManager(); $entities = $em->getRepository('ChillReportBundle:Report')->findAll(); + $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->findByEntity('Chill\ReportBundle\Entity\Report'); + + $cFGroupsChoice = array(); + + foreach ($cFGroups as $g) { + $cFGroupsChoice[$g->getId()] = $g->getName($request->getLocale()); + } + + $form = $this->get('form.factory') + ->createNamedBuilder(null, 'form', null, array( + 'method' => 'GET', + 'action' => $this->generateUrl('report_new'), + 'csrf_protection' => false + )) + ->add('type', 'choice', array( + 'choices' => $cFGroupsChoice + )) + ->getForm(); + return $this->render('ChillReportBundle:Report:index.html.twig', array( 'entities' => $entities, + 'form' => $form->createView() )); } + /** * Creates a new Report entity. * diff --git a/Resources/views/Report/index.html.twig b/Resources/views/Report/index.html.twig index 7cc7549f1..c021d8dbc 100644 --- a/Resources/views/Report/index.html.twig +++ b/Resources/views/Report/index.html.twig @@ -41,11 +41,11 @@ - - {% endblock %} + + {{ form_start(form) }} + {{ form_row(form) }} + + {{ form_end(form) }} +{% endblock %} From c0c36bc1ec765d801287b3f8fffaf2b76fcbe68b Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sat, 8 Nov 2014 18:15:56 +0100 Subject: [PATCH 016/210] cFGroup selection by Id --- Controller/ReportController.php | 36 ++++++++++++++++++++++++++++----- Form/ReportType.php | 18 ++++++++++++++++- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 2e3b068ef..3a5df68cb 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -30,8 +30,8 @@ class ReportController extends Controller $cFGroupsChoice = array(); - foreach ($cFGroups as $g) { - $cFGroupsChoice[$g->getId()] = $g->getName($request->getLocale()); + foreach ($cFGroups as $cFGroup) { + $cFGroupsChoice[$cFGroup->getId()] = $cFGroup->getName($request->getLocale()); } $form = $this->get('form.factory') @@ -40,7 +40,7 @@ class ReportController extends Controller 'action' => $this->generateUrl('report_new'), 'csrf_protection' => false )) - ->add('type', 'choice', array( + ->add('cFGroup', 'choice', array( 'choices' => $cFGroupsChoice )) ->getForm(); @@ -57,7 +57,20 @@ class ReportController extends Controller */ public function createAction(Request $request) { + $em = $this->getDoctrine()->getManager(); + $entity = new Report(); + + $cFGroupId = $request->query->get('cFGroup',null); + echo $cFGroupId; + die(); + + if($cFGroupId) { + $entity.setCFGroup( + $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cFGroupID) + ); + } + $form = $this->createCreateForm($entity); $form->handleRequest($request); @@ -87,6 +100,7 @@ class ReportController extends Controller $form = $this->createForm(new ReportType(), $entity, array( 'action' => $this->generateUrl('report_create'), 'method' => 'POST', + 'em' => $this->getDoctrine()->getManager(), )); $form->add('submit', 'submit', array('label' => 'Create')); @@ -98,10 +112,21 @@ class ReportController extends Controller * Displays a form to create a new Report entity. * */ - public function newAction() + public function newAction(Request $request) { + $em = $this->getDoctrine()->getManager(); + $entity = new Report(); - $form = $this->createCreateForm($entity); + + $cFGroupId = $request->query->get('cFGroup'); + + if($cFGroupId) { + $entity->setCFGroup( + $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cFGroupId) + ); + } + + $form = $this->createCreateForm($entity); return $this->render('ChillReportBundle:Report:new.html.twig', array( 'entity' => $entity, @@ -167,6 +192,7 @@ class ReportController extends Controller $form = $this->createForm(new ReportType(), $entity, array( 'action' => $this->generateUrl('report_update', array('id' => $entity->getId())), 'method' => 'PUT', + 'em' => $this->getDoctrine()->getManager(), )); $form->add('submit', 'submit', array('label' => 'Update')); diff --git a/Form/ReportType.php b/Form/ReportType.php index 566b8201e..065bac978 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -6,6 +6,8 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer; + class ReportType extends AbstractType { /** @@ -14,13 +16,19 @@ class ReportType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { + $entityManager = $options['em']; + $transformer = new CustomFieldsGroupToIdTransformer($entityManager); + $builder ->add('user') ->add('person') ->add('date') ->add('scope') ->add('cFData') - ->add('cFGroup') + ->add( + $builder->create('cFGroup', 'text') + ->addModelTransformer($transformer) + ) ; } @@ -32,6 +40,14 @@ class ReportType extends AbstractType $resolver->setDefaults(array( 'data_class' => 'Chill\ReportBundle\Entity\Report' )); + + $resolver->setRequired(array( + 'em', + )); + + $resolver->setAllowedTypes(array( + 'em' => 'Doctrine\Common\Persistence\ObjectManager', + )); } /** From 0fe396296892e2ca78e31e9aae8a32322ca5864b Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sat, 8 Nov 2014 18:34:19 +0100 Subject: [PATCH 017/210] Adding CustomFieldsData for Report --- Controller/ReportController.php | 14 ++++++++------ Form/ReportType.php | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 3a5df68cb..7cd0288df 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -95,12 +95,13 @@ class ReportController extends Controller * * @return \Symfony\Component\Form\Form The form */ - private function createCreateForm(Report $entity) + private function createCreateForm(Report $entity, $cFGroup) { $form = $this->createForm(new ReportType(), $entity, array( 'action' => $this->generateUrl('report_create'), 'method' => 'POST', 'em' => $this->getDoctrine()->getManager(), + 'cFGroup' => $cFGroup, )); $form->add('submit', 'submit', array('label' => 'Create')); @@ -120,13 +121,14 @@ class ReportController extends Controller $cFGroupId = $request->query->get('cFGroup'); - if($cFGroupId) { - $entity->setCFGroup( - $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cFGroupId) - ); + if(! $cFGroupId) { + throw new Exception("Error Processing Request", 1); } - $form = $this->createCreateForm($entity); + $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cFGroupId); + $entity->setCFGroup($cFGroup); + + $form = $this->createCreateForm($entity, $cFGroup); return $this->render('ChillReportBundle:Report:new.html.twig', array( 'entity' => $entity, diff --git a/Form/ReportType.php b/Form/ReportType.php index 065bac978..2c6e2499e 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -24,7 +24,7 @@ class ReportType extends AbstractType ->add('person') ->add('date') ->add('scope') - ->add('cFData') + ->add('cFData', 'custom_field', array('group' => $options['cFGroup'])) ->add( $builder->create('cFGroup', 'text') ->addModelTransformer($transformer) @@ -43,10 +43,12 @@ class ReportType extends AbstractType $resolver->setRequired(array( 'em', + 'cFGroup', )); $resolver->setAllowedTypes(array( 'em' => 'Doctrine\Common\Persistence\ObjectManager', + 'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup' )); } From 3834e16a7bb156683f75a6710225b8de704b4484 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sun, 9 Nov 2014 19:19:28 +0100 Subject: [PATCH 018/210] Linking report <> person --- Controller/ReportController.php | 33 +++++++++++++++++++ Resources/config/routing.yml | 9 +++++ .../views/Report/select_report_type.html.twig | 13 ++++++++ 3 files changed, 55 insertions(+) create mode 100644 Resources/views/Report/select_report_type.html.twig diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 7cd0288df..1bd09c25a 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -51,6 +51,39 @@ class ReportController extends Controller )); } + + /** + * Select the type of the Report + */ + public function selectReportTypeAction($person_id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + + $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->findByEntity('Chill\ReportBundle\Entity\Report'); + + $cFGroupsChoice = array(); + + foreach ($cFGroups as $cFGroup) { + $cFGroupsChoice[$cFGroup->getId()] = $cFGroup->getName($request->getLocale()); + } + + $form = $this->get('form.factory') + ->createNamedBuilder(null, 'form', null, array( + 'method' => 'GET', + 'action' => $this->generateUrl('report_new'), + 'csrf_protection' => false + )) + ->add('cFGroup', 'choice', array( + 'choices' => $cFGroupsChoice + )) + ->getForm(); + + return $this->render('ChillReportBundle:Report:select_report_type.html.twig', array( + 'form' => $form->createView() + )); + } + /** * Creates a new Report entity. * diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index e9f83604e..909cbf165 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,3 +1,12 @@ +report_select_type: + pattern: /person/{person_id}/report/create + defaults: { _controller: "ChillReportBundle:Report:selectReportType" } + options: + menus: + person: + order: 100 + label: Add a report + cl_custom_fields_report: resource: "@ChillReportBundle/Resources/config/routing/report.yml" prefix: /report \ No newline at end of file diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig new file mode 100644 index 000000000..acaa3c01b --- /dev/null +++ b/Resources/views/Report/select_report_type.html.twig @@ -0,0 +1,13 @@ +{% extends "ChillMainBundle::layout.html.twig" %} + + + {% block content %} + + {{ form_start(form) }} + {{ form_row(form) }} + + {{ form_end(form) }} + +{% endblock %} \ No newline at end of file From c4f50d54d7539debd955b61da899a2fc0cbecb28 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sun, 9 Nov 2014 19:38:26 +0100 Subject: [PATCH 019/210] Adding CFGroup for reports --- DataFixtures/ORM/LoadCustomFieldsGroup.php | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 DataFixtures/ORM/LoadCustomFieldsGroup.php diff --git a/DataFixtures/ORM/LoadCustomFieldsGroup.php b/DataFixtures/ORM/LoadCustomFieldsGroup.php new file mode 100644 index 000000000..1f2882e21 --- /dev/null +++ b/DataFixtures/ORM/LoadCustomFieldsGroup.php @@ -0,0 +1,49 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\PersonBundle\DataFixtures\ORM; + +use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Common\Persistence\ObjectManager; +use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; + +/** + * Load CustomFieldsGroup for Report into database + */ +class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInterface { + public function getOrder() { + return 15000; + } + + public function load(ObjectManager $manager) { + echo "loading customFieldsGroup...\n"; + + for($i=0; $i <= 3; $i++) { + $cFGroup = (new CustomFieldsGroup()) + ->setName(array('fr' => 'CFGroup Report ' . $i)) + ->setEntity('Chill\ReportBundle\Entity\Report'); + + $manager->persist($cFGroup); + } + $manager->flush(); + } +} \ No newline at end of file From 302286c5589701d0bac85b8a780ff6f6a14ec904 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sun, 9 Nov 2014 20:24:23 +0100 Subject: [PATCH 020/210] Creation of a report enable --- Controller/ReportController.php | 89 ++++++++++--------- Form/ReportType.php | 2 - Resources/config/routing.yml | 15 +++- Resources/config/routing/report.yml | 9 -- Resources/views/Report/new.html.twig | 4 +- .../views/Report/select_report_type.html.twig | 3 +- Resources/views/Report/show.html.twig | 2 +- 7 files changed, 65 insertions(+), 59 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 1bd09c25a..a8dc66c40 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -57,6 +57,18 @@ class ReportController extends Controller */ public function selectReportTypeAction($person_id, Request $request) { + $cFGroupId = $request->query->get('cFGroup'); + + echo('----'); + echo($cFGroupId); + echo('----'); + + if($cFGroupId) { + return $this->redirect( + $this->generateUrl('report_new', + array('person_id' => $person_id, 'cf_group_id' => $cFGroupId))); + } + $em = $this->getDoctrine()->getManager(); $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') @@ -71,7 +83,6 @@ class ReportController extends Controller $form = $this->get('form.factory') ->createNamedBuilder(null, 'form', null, array( 'method' => 'GET', - 'action' => $this->generateUrl('report_new'), 'csrf_protection' => false )) ->add('cFGroup', 'choice', array( @@ -85,30 +96,50 @@ class ReportController extends Controller } /** - * Creates a new Report entity. + * Displays a form to create a new Report entity. * */ - public function createAction(Request $request) + public function newAction($person_id, $cf_group_id, Request $request) { $em = $this->getDoctrine()->getManager(); $entity = new Report(); - $cFGroupId = $request->query->get('cFGroup',null); - echo $cFGroupId; - die(); + $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); + $entity->setCFGroup($cFGroup); - if($cFGroupId) { - $entity.setCFGroup( - $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cFGroupID) - ); - } + $form = $this->createCreateForm($entity, $person_id, $cFGroup); - $form = $this->createCreateForm($entity); + return $this->render('ChillReportBundle:Report:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Creates a new Report entity. + * + */ + public function createAction($person_id, $cf_group_id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + + $entity = new Report(); + $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); + + $form = $this->createCreateForm($entity, $person_id, $cFGroup); $form->handleRequest($request); if ($form->isValid()) { - $em = $this->getDoctrine()->getManager(); + $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); + $entity->setCFGroup($cFGroup); + + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $entity->setPerson($person); + + $user = $this->get('security.context')->getToken()->getUser(); + $entity->setUser($user); + $em->persist($entity); $em->flush(); @@ -128,10 +159,11 @@ class ReportController extends Controller * * @return \Symfony\Component\Form\Form The form */ - private function createCreateForm(Report $entity, $cFGroup) + private function createCreateForm(Report $entity, $person_id, $cFGroup) { $form = $this->createForm(new ReportType(), $entity, array( - 'action' => $this->generateUrl('report_create'), + 'action' => $this->generateUrl('report_create', + array('person_id' => $person_id, 'cf_group_id' => $cFGroup->getId())), 'method' => 'POST', 'em' => $this->getDoctrine()->getManager(), 'cFGroup' => $cFGroup, @@ -142,33 +174,6 @@ class ReportController extends Controller return $form; } - /** - * Displays a form to create a new Report entity. - * - */ - public function newAction(Request $request) - { - $em = $this->getDoctrine()->getManager(); - - $entity = new Report(); - - $cFGroupId = $request->query->get('cFGroup'); - - if(! $cFGroupId) { - throw new Exception("Error Processing Request", 1); - } - - $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cFGroupId); - $entity->setCFGroup($cFGroup); - - $form = $this->createCreateForm($entity, $cFGroup); - - return $this->render('ChillReportBundle:Report:new.html.twig', array( - 'entity' => $entity, - 'form' => $form->createView(), - )); - } - /** * Finds and displays a Report entity. * diff --git a/Form/ReportType.php b/Form/ReportType.php index 2c6e2499e..c97cbec31 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -20,8 +20,6 @@ class ReportType extends AbstractType $transformer = new CustomFieldsGroupToIdTransformer($entityManager); $builder - ->add('user') - ->add('person') ->add('date') ->add('scope') ->add('cFData', 'custom_field', array('group' => $options['cFGroup'])) diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 909cbf165..6554b7e4a 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,5 +1,5 @@ report_select_type: - pattern: /person/{person_id}/report/create + pattern: /person/{person_id}/report/select/type/for/creation defaults: { _controller: "ChillReportBundle:Report:selectReportType" } options: menus: @@ -7,6 +7,19 @@ report_select_type: order: 100 label: Add a report +report_new: + path: /person/{person_id}/report/cfgroup/{cf_group_id}/new + defaults: { _controller: "ChillReportBundle:Report:new" } + +report_create: + path: /person/{person_id}/report/cfgroup/{cf_group_id}/create + defaults: { _controller: "ChillReportBundle:Report:create" } + requirements: { _method: post } + +report_show: + path: report/{id}/show + defaults: { _controller: "ChillReportBundle:Report:show" } + cl_custom_fields_report: resource: "@ChillReportBundle/Resources/config/routing/report.yml" prefix: /report \ No newline at end of file diff --git a/Resources/config/routing/report.yml b/Resources/config/routing/report.yml index bb21c22c0..33e0aab6c 100644 --- a/Resources/config/routing/report.yml +++ b/Resources/config/routing/report.yml @@ -6,15 +6,6 @@ report_show: path: /{id}/show defaults: { _controller: "ChillReportBundle:Report:show" } -report_new: - path: /new - defaults: { _controller: "ChillReportBundle:Report:new" } - -report_create: - path: /create - defaults: { _controller: "ChillReportBundle:Report:create" } - requirements: { _method: post } - report_edit: path: /{id}/edit defaults: { _controller: "ChillReportBundle:Report:edit" } diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index dfe5f4320..3a63af29e 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -1,6 +1,6 @@ -{% extends '::base.html.twig' %} +{% extends "ChillMainBundle::layout.html.twig" %} -{% block body -%} +{% block content %}

Report creation

{{ form(form) }} diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index acaa3c01b..1ba18644f 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -1,7 +1,6 @@ {% extends "ChillMainBundle::layout.html.twig" %} - - {% block content %} +{% block content %} {{ form_start(form) }} {{ form_row(form) }} diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/show.html.twig index 064b13b7a..f0c4bdb4a 100644 --- a/Resources/views/Report/show.html.twig +++ b/Resources/views/Report/show.html.twig @@ -11,7 +11,7 @@ Userr - {{ entity.userr }} + {{ entity.user }} Person From 92297aeb396cd574e51bb2598046c25268734521 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sun, 9 Nov 2014 20:34:04 +0100 Subject: [PATCH 021/210] Removing CustomFieldsGroupToIdTransformer --- Form/ReportType.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index c97cbec31..34a655b62 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -6,8 +6,6 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; -use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer; - class ReportType extends AbstractType { /** @@ -17,16 +15,11 @@ class ReportType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $entityManager = $options['em']; - $transformer = new CustomFieldsGroupToIdTransformer($entityManager); $builder ->add('date') ->add('scope') ->add('cFData', 'custom_field', array('group' => $options['cFGroup'])) - ->add( - $builder->create('cFGroup', 'text') - ->addModelTransformer($transformer) - ) ; } From a131633c794dc767747b1e748074985b3b5d2b01 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sun, 9 Nov 2014 20:38:31 +0100 Subject: [PATCH 022/210] Enabling report show (without CFData) --- Resources/views/Report/show.html.twig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/show.html.twig index f0c4bdb4a..920e87592 100644 --- a/Resources/views/Report/show.html.twig +++ b/Resources/views/Report/show.html.twig @@ -1,6 +1,6 @@ -{% extends '::base.html.twig' %} +{% extends "ChillMainBundle::layout.html.twig" %} -{% block body -%} +{% block content %}

Report

@@ -10,7 +10,7 @@ - + @@ -27,11 +27,11 @@ - + - +
{{ entity.id }}
UserrUser {{ entity.user }}
Cfdata{{ entity.cFData }}{# { entity.cFData } #}
Cfgroup{{ entity.cFGroup }}{{ entity.cFGroup.getName(app.request.locale) }}
From f6a237c8227a751f202243fdfff0a001d38a526a Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 09:02:48 +0100 Subject: [PATCH 023/210] Adding copyright --- Resources/views/Report/show.html.twig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/show.html.twig index 920e87592..1f555eaba 100644 --- a/Resources/views/Report/show.html.twig +++ b/Resources/views/Report/show.html.twig @@ -1,3 +1,19 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} {% extends "ChillMainBundle::layout.html.twig" %} {% block content %} From b2baaf4d71285fcc93bed9583c99e7714519617c Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 09:07:39 +0100 Subject: [PATCH 024/210] Debug : user for report --- Entity/Report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Entity/Report.php b/Entity/Report.php index 83b2bfb38..117956cd1 100644 --- a/Entity/Report.php +++ b/Entity/Report.php @@ -84,7 +84,7 @@ class Report */ public function setUser($user) { - $this->userr = $user; + $this->user = $user; return $this; } From a0f174a77bb280813b7897c253cc65c5fef0fcc2 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 09:33:43 +0100 Subject: [PATCH 025/210] Removing code for debugging --- Controller/ReportController.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index a8dc66c40..69e120d0c 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -59,10 +59,6 @@ class ReportController extends Controller { $cFGroupId = $request->query->get('cFGroup'); - echo('----'); - echo($cFGroupId); - echo('----'); - if($cFGroupId) { return $this->redirect( $this->generateUrl('report_new', From c1a76327d7a0e389cfea3e0a29da98b0e6c0b560 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 09:34:23 +0100 Subject: [PATCH 026/210] Improving Fixtures CustomFieldsGroup for Report --- DataFixtures/ORM/LoadCustomFieldsGroup.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/DataFixtures/ORM/LoadCustomFieldsGroup.php b/DataFixtures/ORM/LoadCustomFieldsGroup.php index 1f2882e21..5b43edd10 100644 --- a/DataFixtures/ORM/LoadCustomFieldsGroup.php +++ b/DataFixtures/ORM/LoadCustomFieldsGroup.php @@ -29,20 +29,25 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; /** * Load CustomFieldsGroup for Report into database */ -class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInterface { - public function getOrder() { +class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInterface +{ + public function getOrder() + { return 15000; } - public function load(ObjectManager $manager) { + public function load(ObjectManager $manager) + { echo "loading customFieldsGroup...\n"; for($i=0; $i <= 3; $i++) { + echo "CFGroup Report {$i}\n"; $cFGroup = (new CustomFieldsGroup()) ->setName(array('fr' => 'CFGroup Report ' . $i)) ->setEntity('Chill\ReportBundle\Entity\Report'); $manager->persist($cFGroup); + $this->addReference('cf_group_report_'.$i, $cFGroup); } $manager->flush(); } From 26a0c860e23e4694d2956f0dcc84a8e31db8132c Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 09:52:38 +0100 Subject: [PATCH 027/210] Adding Fixtures : CustomField for Report --- DataFixtures/ORM/LoadCustomField.php | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 DataFixtures/ORM/LoadCustomField.php diff --git a/DataFixtures/ORM/LoadCustomField.php b/DataFixtures/ORM/LoadCustomField.php new file mode 100644 index 000000000..2ae38da93 --- /dev/null +++ b/DataFixtures/ORM/LoadCustomField.php @@ -0,0 +1,66 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\PersonBundle\DataFixtures\ORM; + +use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Common\Persistence\ObjectManager; +use Chill\CustomFieldsBundle\Entity\CustomField; + +/** + * Load CustomField for Report into database + */ +class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface +{ + public function getOrder() + { + return 15001; + } + + public function load(ObjectManager $manager) + { + echo "loading CustomField...\n"; + + $cFTypes = [ + array('type' => 'text', 'options' => array('maxLength' => '255')), + array('type' => 'text', 'options' => array('maxLength' => '1000')), + array('type' => 'text', 'options' => array('maxLength' => '2000')), + ]; + + for($i=0; $i <= 25; $i++) { + echo "CustomField {$i}\n"; + $cFType = $cFTypes[rand(0,sizeof($cFTypes) - 1)]; + + $customField = (new CustomField()) + ->setSlug("cf_report_{$i}") + ->setType($cFType['type']) + ->setOptions($cFType['options']) + ->setName(array("fr" => "CustomField {$i}")) + ->setOrdering(rand(0,1000) / 1000) + ->setCustomFieldsGroup($this->getReference('cf_group_report_'.(rand(0,3)))) + ; + + $manager->persist($customField); + } + $manager->flush(); + } +} \ No newline at end of file From 6a5f24a898c0d5bce31fa223855c8b145b6607d6 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 09:54:23 +0100 Subject: [PATCH 028/210] Adding copyright --- Controller/ReportController.php | 19 +++++++++++++++++++ Form/ReportType.php | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 69e120d0c..52093da85 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -1,5 +1,24 @@ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\ReportBundle\Controller; use Symfony\Component\HttpFoundation\Request; diff --git a/Form/ReportType.php b/Form/ReportType.php index 34a655b62..3da6397aa 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -1,5 +1,24 @@ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\ReportBundle\Form; use Symfony\Component\Form\AbstractType; From 88e8b55317e98acfa1bee2bff9ab161c8fc8bf93 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 12:34:54 +0100 Subject: [PATCH 029/210] select_report_type : person template --- Controller/ReportController.php | 5 ++++- Resources/views/Report/select_report_type.html.twig | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 52093da85..caf8eaf47 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -86,6 +86,8 @@ class ReportController extends Controller $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') ->findByEntity('Chill\ReportBundle\Entity\Report'); @@ -106,7 +108,8 @@ class ReportController extends Controller ->getForm(); return $this->render('ChillReportBundle:Report:select_report_type.html.twig', array( - 'form' => $form->createView() + 'form' => $form->createView(), + 'person' => $person )); } diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index 1ba18644f..068bd966c 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -1,6 +1,8 @@ -{% extends "ChillMainBundle::layout.html.twig" %} +{% extends "ChillPersonBundle::layout.html.twig" %} -{% block content %} +{% set activeRouteKey = 'report_select_type' %} + +{% block personcontent %} {{ form_start(form) }} {{ form_row(form) }} From a3c67dd9b0aade36a91f207d5d18b7c3e0d02dfc Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 12:41:35 +0100 Subject: [PATCH 030/210] Adding title for select_report_type.html.twig --- Resources/views/Report/select_report_type.html.twig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index 068bd966c..af46ca14a 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -2,6 +2,8 @@ {% set activeRouteKey = 'report_select_type' %} +{% block title %}{{ 'Ajout d\' un rapport' |trans() }}{% endblock title %} + {% block personcontent %} {{ form_start(form) }} From bd4538604e01cffdbe31e5cfe064acdfaded6b22 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 12:51:52 +0100 Subject: [PATCH 031/210] using person template --- Controller/ReportController.php | 17 +++++++--- Resources/config/routing.yml | 3 +- Resources/config/routing/report.yml | 4 --- Resources/views/Report/new.html.twig | 32 ++++++++++++------- .../views/Report/select_report_type.html.twig | 16 ++++++++++ Resources/views/Report/show.html.twig | 22 +++---------- 6 files changed, 55 insertions(+), 39 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index caf8eaf47..eee4ca4cf 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -121,6 +121,8 @@ class ReportController extends Controller { $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $entity = new Report(); $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); @@ -131,6 +133,7 @@ class ReportController extends Controller return $this->render('ChillReportBundle:Report:new.html.twig', array( 'entity' => $entity, 'form' => $form->createView(), + 'person' => $person )); } @@ -161,7 +164,8 @@ class ReportController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('report_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('report_show', + array('person_id' => $person_id,'id' => $entity->getId()))); } return $this->render('ChillReportBundle:Report:new.html.twig', array( @@ -196,21 +200,24 @@ class ReportController extends Controller * Finds and displays a Report entity. * */ - public function showAction($id) + public function showAction($id, $person_id) { $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $entity = $em->getRepository('ChillReportBundle:Report')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Report entity.'); } - $deleteForm = $this->createDeleteForm($id); + //$deleteForm = $this->createDeleteForm($id); return $this->render('ChillReportBundle:Report:show.html.twig', array( - 'entity' => $entity, - 'delete_form' => $deleteForm->createView(), + 'entity' => $entity, + 'person' => $person, + //'delete_form' => $deleteForm->createView(), )); } diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 6554b7e4a..e7ada1e7d 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -6,7 +6,6 @@ report_select_type: person: order: 100 label: Add a report - report_new: path: /person/{person_id}/report/cfgroup/{cf_group_id}/new defaults: { _controller: "ChillReportBundle:Report:new" } @@ -17,7 +16,7 @@ report_create: requirements: { _method: post } report_show: - path: report/{id}/show + path: /person/{person_id}/report/{id}/show defaults: { _controller: "ChillReportBundle:Report:show" } cl_custom_fields_report: diff --git a/Resources/config/routing/report.yml b/Resources/config/routing/report.yml index 33e0aab6c..fe0bba6d9 100644 --- a/Resources/config/routing/report.yml +++ b/Resources/config/routing/report.yml @@ -2,10 +2,6 @@ report: path: / defaults: { _controller: "ChillReportBundle:Report:index" } -report_show: - path: /{id}/show - defaults: { _controller: "ChillReportBundle:Report:show" } - report_edit: path: /{id}/edit defaults: { _controller: "ChillReportBundle:Report:edit" } diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index 3a63af29e..5277d10f9 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -1,15 +1,25 @@ -{% extends "ChillMainBundle::layout.html.twig" %} +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} -{% block content %} -

Report creation

+{% set activeRouteKey = 'report_select_type' %} +{% block title %}{{ 'Ajout d\' un rapport' |trans() }}{% endblock title %} + +{% block personcontent %} {{ form(form) }} - - {% endblock %} diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index af46ca14a..b5b609eec 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -1,3 +1,19 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} {% extends "ChillPersonBundle::layout.html.twig" %} {% set activeRouteKey = 'report_select_type' %} diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/show.html.twig index 1f555eaba..3528da240 100644 --- a/Resources/views/Report/show.html.twig +++ b/Resources/views/Report/show.html.twig @@ -14,11 +14,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "ChillMainBundle::layout.html.twig" %} +{% extends "ChillPersonBundle::layout.html.twig" %} -{% block content %} -

Report

+{% set activeRouteKey = 'report_select_type' %} +{% block title %}{{ 'Details d\' un rapport' |trans() }}{% endblock title %} + +{% block personcontent %} @@ -51,18 +53,4 @@
- - {% endblock %} \ No newline at end of file From bdb3e9eabe0244de25488302edec9e7f8d6bd06c Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 11 Nov 2014 12:16:59 +0100 Subject: [PATCH 032/210] Adding date picker for report --- Form/ReportType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index 3da6397aa..181571c4a 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -36,7 +36,7 @@ class ReportType extends AbstractType $entityManager = $options['em']; $builder - ->add('date') + ->add('date', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) ->add('scope') ->add('cFData', 'custom_field', array('group' => $options['cFGroup'])) ; From c120c32064a26a780910542b1e2ce5d6aca2f28a Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 11 Nov 2014 15:19:17 +0100 Subject: [PATCH 033/210] Report Choice Form - Formatting --- Form/ReportType.php | 2 +- .../views/Report/select_report_type.html.twig | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index 181571c4a..c253e416e 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -38,7 +38,7 @@ class ReportType extends AbstractType $builder ->add('date', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) ->add('scope') - ->add('cFData', 'custom_field', array('group' => $options['cFGroup'])) + ->add('cFData', 'custom_field', array('attr' => array('class' => 'only-label'), 'group' => $options['cFGroup'])) ; } diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index b5b609eec..0930bda4e 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -22,11 +22,14 @@ {% block personcontent %} - {{ form_start(form) }} - {{ form_row(form) }} - - {{ form_end(form) }} + +{{ form_start(form) }} + {{ form_row(form.cFGroup) }} + + +{{ form_end(form) }} + {% endblock %} \ No newline at end of file From 6d39e981972238f76cb0785bfe9f941a5350af15 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 11 Nov 2014 15:37:04 +0100 Subject: [PATCH 034/210] Enable report list --- Controller/ReportController.php | 30 +++------------ Resources/config/routing.yml | 9 +++++ Resources/views/Report/index.html.twig | 51 -------------------------- Resources/views/Report/list.html.twig | 44 ++++++++++++++++++++++ 4 files changed, 59 insertions(+), 75 deletions(-) delete mode 100644 Resources/views/Report/index.html.twig create mode 100644 Resources/views/Report/list.html.twig diff --git a/Controller/ReportController.php b/Controller/ReportController.php index eee4ca4cf..37a832acb 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -38,35 +38,17 @@ class ReportController extends Controller * Lists all Report entities. * */ - public function indexAction(Request $request) + public function listAction($person_id, Request $request) { $em = $this->getDoctrine()->getManager(); - $entities = $em->getRepository('ChillReportBundle:Report')->findAll(); + $reports = $em->getRepository('ChillReportBundle:Report')->findByPerson($person_id); - $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') - ->findByEntity('Chill\ReportBundle\Entity\Report'); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - $cFGroupsChoice = array(); - - foreach ($cFGroups as $cFGroup) { - $cFGroupsChoice[$cFGroup->getId()] = $cFGroup->getName($request->getLocale()); - } - - $form = $this->get('form.factory') - ->createNamedBuilder(null, 'form', null, array( - 'method' => 'GET', - 'action' => $this->generateUrl('report_new'), - 'csrf_protection' => false - )) - ->add('cFGroup', 'choice', array( - 'choices' => $cFGroupsChoice - )) - ->getForm(); - - return $this->render('ChillReportBundle:Report:index.html.twig', array( - 'entities' => $entities, - 'form' => $form->createView() + return $this->render('ChillReportBundle:Report:list.html.twig', array( + 'reports' => $reports, + 'person' => $person )); } diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index e7ada1e7d..73c24c81f 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -15,6 +15,15 @@ report_create: defaults: { _controller: "ChillReportBundle:Report:create" } requirements: { _method: post } +report_list: + path: /person/{person_id}/report/list + defaults: { _controller: "ChillReportBundle:Report:list" } + options: + menus: + person: + order: 101 + label: Report list + report_show: path: /person/{person_id}/report/{id}/show defaults: { _controller: "ChillReportBundle:Report:show" } diff --git a/Resources/views/Report/index.html.twig b/Resources/views/Report/index.html.twig deleted file mode 100644 index c021d8dbc..000000000 --- a/Resources/views/Report/index.html.twig +++ /dev/null @@ -1,51 +0,0 @@ -{% extends '::base.html.twig' %} - -{% block body -%} -

Report list

- - - - - - - - - - - - - - - - {% for entity in entities %} - - - - - - - - - - - {% endfor %} - -
IdUserrPersonDateScopeCfdataCfgroupActions
{{ entity.id }}{{ entity.userr }}{{ entity.person }}{% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif %}{{ entity.scope }}{{ entity.cFData }}{{ entity.cFGroup }} - -
- - - {{ form_start(form) }} - {{ form_row(form) }} - - {{ form_end(form) }} -{% endblock %} diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig new file mode 100644 index 000000000..f92269d75 --- /dev/null +++ b/Resources/views/Report/list.html.twig @@ -0,0 +1,44 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} + +{% set activeRouteKey = 'report_select_type' %} + +{% block title %}{{ 'List des rapports' |trans() }}{% endblock title %} + +{% block personcontent %} + + + + + + + + + + + {% for report in reports %} + + + + + + + {% endfor %} + +
{{ 'Date' | trans }}{{ 'Report Type' | trans }}{{ 'Report Scope' | trans }}
{% if report.date %}{{ report.date|date('d-m-Y') }}{% endif %}{{ report.cFGroup.getName(app.request.locale) }}{{ report.scope }}{{ 'update' | trans }}
+{% endblock %} From f74e3db1930c275ac41fc9f88715929ce7654c34 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 11 Nov 2014 15:37:37 +0100 Subject: [PATCH 035/210] Date to d-m-Y --- Resources/views/Report/show.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/show.html.twig index 3528da240..b6fbcee20 100644 --- a/Resources/views/Report/show.html.twig +++ b/Resources/views/Report/show.html.twig @@ -37,7 +37,7 @@ Date - {{ entity.date|date('Y-m-d H:i:s') }} + {{ entity.date|date('d-m-Y') }} Scope From bdbcdd2db95b8a55f6f7d732aa0bd08447a63cbf Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 11 Nov 2014 15:40:56 +0100 Subject: [PATCH 036/210] Removing delete action --- Controller/ReportController.php | 43 --------------------------------- 1 file changed, 43 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 37a832acb..ef5596b4b 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -194,12 +194,9 @@ class ReportController extends Controller throw $this->createNotFoundException('Unable to find Report entity.'); } - //$deleteForm = $this->createDeleteForm($id); - return $this->render('ChillReportBundle:Report:show.html.twig', array( 'entity' => $entity, 'person' => $person, - //'delete_form' => $deleteForm->createView(), )); } @@ -276,44 +273,4 @@ class ReportController extends Controller 'delete_form' => $deleteForm->createView(), )); } - /** - * Deletes a Report entity. - * - */ - public function deleteAction(Request $request, $id) - { - $form = $this->createDeleteForm($id); - $form->handleRequest($request); - - if ($form->isValid()) { - $em = $this->getDoctrine()->getManager(); - $entity = $em->getRepository('ChillReportBundle:Report')->find($id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find Report entity.'); - } - - $em->remove($entity); - $em->flush(); - } - - return $this->redirect($this->generateUrl('report')); - } - - /** - * Creates a form to delete a Report entity by id. - * - * @param mixed $id The entity id - * - * @return \Symfony\Component\Form\Form The form - */ - private function createDeleteForm($id) - { - return $this->createFormBuilder() - ->setAction($this->generateUrl('report_delete', array('id' => $id))) - ->setMethod('DELETE') - ->add('submit', 'submit', array('label' => 'Delete')) - ->getForm() - ; - } } From 2ae19eba39e3300f8f1469090d2aa69aae0f1d84 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 11 Nov 2014 16:07:44 +0100 Subject: [PATCH 037/210] Updating report --- Controller/ReportController.php | 62 +++++++++++++++------------ Resources/config/routing.yml | 14 +++--- Resources/config/routing/report.yml | 17 -------- Resources/views/Report/edit.html.twig | 33 +++++++++----- Resources/views/Report/list.html.twig | 2 +- Resources/views/Report/show.html.twig | 4 ++ 6 files changed, 70 insertions(+), 62 deletions(-) delete mode 100644 Resources/config/routing/report.yml diff --git a/Controller/ReportController.php b/Controller/ReportController.php index ef5596b4b..8da41ce0d 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -147,7 +147,7 @@ class ReportController extends Controller $em->flush(); return $this->redirect($this->generateUrl('report_show', - array('person_id' => $person_id,'id' => $entity->getId()))); + array('person_id' => $person_id,'report_id' => $entity->getId()))); } return $this->render('ChillReportBundle:Report:new.html.twig', array( @@ -182,13 +182,13 @@ class ReportController extends Controller * Finds and displays a Report entity. * */ - public function showAction($id, $person_id) + public function showAction($report_id, $person_id) { $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - $entity = $em->getRepository('ChillReportBundle:Report')->find($id); + $entity = $em->getRepository('ChillReportBundle:Report')->find($report_id); if (!$entity) { throw $this->createNotFoundException('Unable to find Report entity.'); @@ -204,73 +204,79 @@ class ReportController extends Controller * Displays a form to edit an existing Report entity. * */ - public function editAction($id) + public function editAction($person_id, $report_id, Request $request) { $em = $this->getDoctrine()->getManager(); - $entity = $em->getRepository('ChillReportBundle:Report')->find($id); + $report = $em->getRepository('ChillReportBundle:Report')->find($report_id); - if (!$entity) { - throw $this->createNotFoundException('Unable to find Report entity.'); + if (!$report) { + throw $this->createNotFoundException('Unable to find the report.'); } - $editForm = $this->createEditForm($entity); - $deleteForm = $this->createDeleteForm($id); + if(intval($person_id) !== intval($report->getPerson()->getId())) { + throw new Exception("This is not the report of the person", 1); + } + + $person = $report->getPerson(); + + $editForm = $this->createEditForm($report, $person->getId()); return $this->render('ChillReportBundle:Report:edit.html.twig', array( - 'entity' => $entity, 'edit_form' => $editForm->createView(), - 'delete_form' => $deleteForm->createView(), + 'person' => $person, )); } /** - * Creates a form to edit a Report entity. - * - * @param Report $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createEditForm(Report $entity) + * Creates a form to edit a Report entity. + * + * @param Report $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createEditForm(Report $entity, $person_id) { $form = $this->createForm(new ReportType(), $entity, array( - 'action' => $this->generateUrl('report_update', array('id' => $entity->getId())), + 'action' => $this->generateUrl('report_update', + array('person_id' => $person_id, 'report_id' => $entity->getId())), 'method' => 'PUT', 'em' => $this->getDoctrine()->getManager(), + 'cFGroup' => $entity->getCFGroup(), )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; } + /** * Edits an existing Report entity. * */ - public function updateAction(Request $request, $id) + public function updateAction($person_id, $report_id, Request $request) { $em = $this->getDoctrine()->getManager(); - $entity = $em->getRepository('ChillReportBundle:Report')->find($id); + $report = $em->getRepository('ChillReportBundle:Report')->find($report_id); - if (!$entity) { - throw $this->createNotFoundException('Unable to find Report entity.'); + if (!$report) { + throw $this->createNotFoundException('Unable to find the report '.$report_id.'.'); } - $deleteForm = $this->createDeleteForm($id); - $editForm = $this->createEditForm($entity); + $editForm = $this->createEditForm($report, $person_id); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('report_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('report_edit', + array('person_id' => $report->getPerson()->getId(), 'report_id' => $report_id))); } return $this->render('ChillReportBundle:Report:edit.html.twig', array( - 'entity' => $entity, 'edit_form' => $editForm->createView(), - 'delete_form' => $deleteForm->createView(), + 'person' => $person )); } } diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 73c24c81f..c4c9ab1a2 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -23,11 +23,15 @@ report_list: person: order: 101 label: Report list - report_show: - path: /person/{person_id}/report/{id}/show + path: /person/{person_id}/report/{report_id}/show defaults: { _controller: "ChillReportBundle:Report:show" } -cl_custom_fields_report: - resource: "@ChillReportBundle/Resources/config/routing/report.yml" - prefix: /report \ No newline at end of file +report_edit: + path: /person/{person_id}/report/{report_id}/edit + defaults: { _controller: "ChillReportBundle:Report:edit" } + +report_update: + path: /person/{person_id}/report/{report_id}/update + defaults: { _controller: "ChillReportBundle:Report:update" } + requirements: { _method: post|put } \ No newline at end of file diff --git a/Resources/config/routing/report.yml b/Resources/config/routing/report.yml deleted file mode 100644 index fe0bba6d9..000000000 --- a/Resources/config/routing/report.yml +++ /dev/null @@ -1,17 +0,0 @@ -report: - path: / - defaults: { _controller: "ChillReportBundle:Report:index" } - -report_edit: - path: /{id}/edit - defaults: { _controller: "ChillReportBundle:Report:edit" } - -report_update: - path: /{id}/update - defaults: { _controller: "ChillReportBundle:Report:update" } - requirements: { _method: post|put } - -report_delete: - path: /{id}/delete - defaults: { _controller: "ChillReportBundle:Report:delete" } - requirements: { _method: post|delete } diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index 407ec3a55..7779b87a4 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -1,16 +1,27 @@ -{% extends '::base.html.twig' %} +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} -{% block body -%} -

Report edit

+{% set activeRouteKey = 'report_select_type' %} + +{% block title %}{{ 'Edition du rapport' |trans() }}{% endblock title %} + +{% block personcontent %} {{ form(edit_form) }} - {% endblock %} diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index f92269d75..bf5e53ee2 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -36,7 +36,7 @@ {% if report.date %}{{ report.date|date('d-m-Y') }}{% endif %} {{ report.cFGroup.getName(app.request.locale) }} {{ report.scope }} - {{ 'update' | trans }} + {{ 'update' | trans }} {% endfor %} diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/show.html.twig index b6fbcee20..539ac25ca 100644 --- a/Resources/views/Report/show.html.twig +++ b/Resources/views/Report/show.html.twig @@ -51,6 +51,10 @@ Cfgroup {{ entity.cFGroup.getName(app.request.locale) }} + + + {{ 'update' | trans }} + {% endblock %} \ No newline at end of file From db31cf836eba2413b68c1daf982c468dc408b960 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 11 Nov 2014 16:33:16 +0100 Subject: [PATCH 038/210] Title and choice for fixtures --- DataFixtures/ORM/LoadCustomField.php | 33 +++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/DataFixtures/ORM/LoadCustomField.php b/DataFixtures/ORM/LoadCustomField.php index 2ae38da93..4ed55542d 100644 --- a/DataFixtures/ORM/LoadCustomField.php +++ b/DataFixtures/ORM/LoadCustomField.php @@ -44,7 +44,38 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface array('type' => 'text', 'options' => array('maxLength' => '255')), array('type' => 'text', 'options' => array('maxLength' => '1000')), array('type' => 'text', 'options' => array('maxLength' => '2000')), - ]; + array('type' => 'title', 'options' => array('type' => 'title')), + array('type' => 'title', 'options' => array('type' => 'subtitle')), + array('type' => 'choice', 'options' => array( + 'multiple' => false, + 'expanded'=> false, + 'other' => false, + 'choices'=> [ + array( + 'name' => array( + 'fr' => 'Options 1 FR', + 'nl' => 'Options 1 NL', + 'en' => 'Options 1 EN'), + 'active' => true, + 'slug' => 'el-1-fr'), + array( + 'name' => array( + 'fr' => 'Options 2 FR', + 'nl' => 'Options 2 NL', + 'en' => 'Options 2 EN'), + 'active' => true, + 'slug' => 'el-2-fr'), + array( + 'name' => array( + 'fr' => 'Options 2 FR', + 'nl' => 'Options 2 NL', + 'en' => 'Options 2 EN'), + 'active' => true, + 'slug' => 'el-3-fr') + ] + ) + ) + ]; for($i=0; $i <= 25; $i++) { echo "CustomField {$i}\n"; From 1ab9b44737c153841b65825a015c339981285406 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 12 Nov 2014 12:35:57 +0100 Subject: [PATCH 039/210] Report View CF --- Resources/views/Report/list.html.twig | 4 +- Resources/views/Report/show.html.twig | 66 ++++++++++++--------------- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index bf5e53ee2..a14b373e8 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -28,6 +28,7 @@ {{ 'Report Type' | trans }} {{ 'Report Scope' | trans }} + @@ -36,7 +37,8 @@ {% if report.date %}{{ report.date|date('d-m-Y') }}{% endif %} {{ report.cFGroup.getName(app.request.locale) }} {{ report.scope }} - {{ 'update' | trans }} + {{ 'View' | trans }} + {{ 'Update' | trans }} {% endfor %} diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/show.html.twig index 539ac25ca..2579bdeb8 100644 --- a/Resources/views/Report/show.html.twig +++ b/Resources/views/Report/show.html.twig @@ -21,40 +21,34 @@ {% block title %}{{ 'Details d\' un rapport' |trans() }}{% endblock title %} {% block personcontent %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Id{{ entity.id }}
User{{ entity.user }}
Person{{ entity.person }}
Date{{ entity.date|date('d-m-Y') }}
Scope{{ entity.scope }}
Cfdata{# { entity.cFData } #}
Cfgroup{{ entity.cFGroup.getName(app.request.locale) }}
{{ 'update' | trans }}
+ + + {{ 'Modifier' | trans }} + +

{{ 'Details'|trans }}

+ +
+
{{ 'Personne'|trans }}
+
{{ entity.person }}
+
{{ 'Scope'|trans }}
+
{{ entity.scope }}
+
{{ 'Date'|trans }}
+
{{ entity.date|date('d-m-Y') }}
+
{{ 'Agent'|trans }}
+
{{ entity.user }}
+
{{ 'Type de rapport'|trans }}
+
{{ entity.cFGroup.getName(app.request.locale) }}
+ + {% for customField in entity.cFGroup.customFields %} + {% if customField.type == 'title' %} + {{ chill_custom_field_widget(entity.cFData , customField) }} + {% else %} +
{{ chill_custom_field_label(customField) }}
+
{{ chill_custom_field_widget(entity.cFData , customField) }}
+ {% endif %} + {% endfor %} +
+ + {{ 'Modifier' | trans }} + {% endblock %} \ No newline at end of file From b91776c5945e6729045a27c4f8709a8c651f3dd6 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 12 Nov 2014 12:39:52 +0100 Subject: [PATCH 040/210] show -> view --- Controller/ReportController.php | 6 +++--- Resources/config/routing.yml | 6 +++--- Resources/views/Report/list.html.twig | 2 +- Resources/views/Report/{show.html.twig => view.html.twig} | 0 4 files changed, 7 insertions(+), 7 deletions(-) rename Resources/views/Report/{show.html.twig => view.html.twig} (100%) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 8da41ce0d..8d505eecf 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -146,7 +146,7 @@ class ReportController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('report_show', + return $this->redirect($this->generateUrl('report_view', array('person_id' => $person_id,'report_id' => $entity->getId()))); } @@ -182,7 +182,7 @@ class ReportController extends Controller * Finds and displays a Report entity. * */ - public function showAction($report_id, $person_id) + public function viewAction($report_id, $person_id) { $em = $this->getDoctrine()->getManager(); @@ -194,7 +194,7 @@ class ReportController extends Controller throw $this->createNotFoundException('Unable to find Report entity.'); } - return $this->render('ChillReportBundle:Report:show.html.twig', array( + return $this->render('ChillReportBundle:Report:view.html.twig', array( 'entity' => $entity, 'person' => $person, )); diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index c4c9ab1a2..2e1ae0198 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -23,9 +23,9 @@ report_list: person: order: 101 label: Report list -report_show: - path: /person/{person_id}/report/{report_id}/show - defaults: { _controller: "ChillReportBundle:Report:show" } +report_view: + path: /person/{person_id}/report/{report_id}/view + defaults: { _controller: "ChillReportBundle:Report:view" } report_edit: path: /person/{person_id}/report/{report_id}/edit diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index a14b373e8..fcc9eb600 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -37,7 +37,7 @@ {% if report.date %}{{ report.date|date('d-m-Y') }}{% endif %} {{ report.cFGroup.getName(app.request.locale) }} {{ report.scope }} - {{ 'View' | trans }} + {{ 'View' | trans }} {{ 'Update' | trans }} {% endfor %} diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/view.html.twig similarity index 100% rename from Resources/views/Report/show.html.twig rename to Resources/views/Report/view.html.twig From 88510942e586addc4d78b28e5ff610b643321a05 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 12 Nov 2014 12:49:02 +0100 Subject: [PATCH 041/210] choice of user in form --- Controller/ReportController.php | 4 +--- Form/ReportType.php | 7 +++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 8d505eecf..29768a128 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -106,6 +106,7 @@ class ReportController extends Controller $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $entity = new Report(); + $entity->setUser($this->get('security.context')->getToken()->getUser()); $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); $entity->setCFGroup($cFGroup); @@ -139,9 +140,6 @@ class ReportController extends Controller $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $entity->setPerson($person); - - $user = $this->get('security.context')->getToken()->getUser(); - $entity->setUser($user); $em->persist($entity); $em->flush(); diff --git a/Form/ReportType.php b/Form/ReportType.php index c253e416e..4ee34a48f 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -36,9 +36,12 @@ class ReportType extends AbstractType $entityManager = $options['em']; $builder - ->add('date', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) + ->add('user') + ->add('date', 'date', + array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) ->add('scope') - ->add('cFData', 'custom_field', array('attr' => array('class' => 'only-label'), 'group' => $options['cFGroup'])) + ->add('cFData', 'custom_field', + array('attr' => array('class' => 'only-label'), 'group' => $options['cFGroup'])) ; } From 555f0191320521f69244d10c26bbd3c73fbc8b96 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 12 Nov 2014 12:49:22 +0100 Subject: [PATCH 042/210] icon for update --- Resources/views/Report/view.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 2579bdeb8..5bd7d7ad4 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -23,7 +23,7 @@ {% block personcontent %} - {{ 'Modifier' | trans }} + {{ 'Update' | trans }}

{{ 'Details'|trans }}

@@ -49,6 +49,6 @@ {% endfor %} - {{ 'Modifier' | trans }} + {{ 'Update' | trans }} {% endblock %} \ No newline at end of file From 8220dfc518a2f273c031d78b8c69f4a0297601db Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 12 Nov 2014 13:09:10 +0100 Subject: [PATCH 043/210] Flash message for actions --- Controller/ReportController.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 29768a128..b09fa416e 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -144,13 +144,26 @@ class ReportController extends Controller $em->persist($entity); $em->flush(); + $this->get('session') + ->getFlashBag() + ->add('success', + $this->get('translator') + ->trans('Report created') + ); + return $this->redirect($this->generateUrl('report_view', array('person_id' => $person_id,'report_id' => $entity->getId()))); } + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + + $this->get('session') + ->getFlashBag()->add('danger', 'Errors : the report has not been created !'); + return $this->render('ChillReportBundle:Report:new.html.twig', array( 'entity' => $entity, 'form' => $form->createView(), + 'person' => $person )); } @@ -268,13 +281,25 @@ class ReportController extends Controller if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('report_edit', + $this->get('session') + ->getFlashBag() + ->add('success', + $this->get('translator') + ->trans('Report updated') + ); + + return $this->redirect($this->generateUrl('report_view', array('person_id' => $report->getPerson()->getId(), 'report_id' => $report_id))); } + $errors = $editForm->getErrorsAsString(); + + $this->get('session') + ->getFlashBag()->add('danger', 'Errors : the report has not been updated !'); + return $this->render('ChillReportBundle:Report:edit.html.twig', array( 'edit_form' => $editForm->createView(), - 'person' => $person + 'person' => $report->getPerson() )); } } From fb90d290cfb3abb912034bba6cff77bf43259b14 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 12 Nov 2014 15:47:00 +0100 Subject: [PATCH 044/210] Adding locale selection --- Resources/config/routing.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 2e1ae0198..187bc6986 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,5 +1,5 @@ report_select_type: - pattern: /person/{person_id}/report/select/type/for/creation + pattern: /{_locale}/person/{person_id}/report/select/type/for/creation defaults: { _controller: "ChillReportBundle:Report:selectReportType" } options: menus: @@ -7,16 +7,16 @@ report_select_type: order: 100 label: Add a report report_new: - path: /person/{person_id}/report/cfgroup/{cf_group_id}/new + path: /{_locale}/person/{person_id}/report/cfgroup/{cf_group_id}/new defaults: { _controller: "ChillReportBundle:Report:new" } report_create: - path: /person/{person_id}/report/cfgroup/{cf_group_id}/create + path: /{_locale}/person/{person_id}/report/cfgroup/{cf_group_id}/create defaults: { _controller: "ChillReportBundle:Report:create" } requirements: { _method: post } report_list: - path: /person/{person_id}/report/list + path: /{_locale}/person/{person_id}/report/list defaults: { _controller: "ChillReportBundle:Report:list" } options: menus: @@ -24,14 +24,14 @@ report_list: order: 101 label: Report list report_view: - path: /person/{person_id}/report/{report_id}/view + path: /{_locale}/person/{person_id}/report/{report_id}/view defaults: { _controller: "ChillReportBundle:Report:view" } report_edit: - path: /person/{person_id}/report/{report_id}/edit + path: /{_locale}/person/{person_id}/report/{report_id}/edit defaults: { _controller: "ChillReportBundle:Report:edit" } report_update: - path: /person/{person_id}/report/{report_id}/update + path: /{_locale}/person/{person_id}/report/{report_id}/update defaults: { _controller: "ChillReportBundle:Report:update" } requirements: { _method: post|put } \ No newline at end of file From 4a035d27d77cec14010436b6395a6a2622aa7bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 13 Nov 2014 15:36:53 +0100 Subject: [PATCH 045/210] create script import of custom fields --- Command/CreateFieldsOnReportsCommand.php | 201 +++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 Command/CreateFieldsOnReportsCommand.php diff --git a/Command/CreateFieldsOnReportsCommand.php b/Command/CreateFieldsOnReportsCommand.php new file mode 100644 index 000000000..29da7f194 --- /dev/null +++ b/Command/CreateFieldsOnReportsCommand.php @@ -0,0 +1,201 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ReportBundle\Command; + + +use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; +use Symfony\Component\Yaml\Parser; +use Symfony\Component\Yaml\Exception\ParseException; +use Chill\CustomFieldsBundle\Entity\CustomField; + +/** + * + * + * @author Julien Fastré + */ +class CreateFieldsOnReportsCommand extends ContainerAwareCommand +{ + + const ARG_PATH = 'path'; + const ARG_DELETE = 'delete'; + + protected function configure() + { + $this->setName('chill:report:custom_fields:create') + ->setDescription('Associate custom fields on reports. Fields must be ' + . 'described in a yml file.') + ->addArgument(self::ARG_PATH, InputOption::VALUE_REQUIRED, + 'Path to description file') + ->addOption(self::ARG_DELETE, null, InputOption::VALUE_NONE, + 'If set, delete existing fields') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $dialog = $this->getHelperSet()->get('dialog'); + $em = $this->getContainer() + ->get('doctrine.orm.default_entity_manager'); + + $customFieldsGroups = $em + ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->findBy(array('entity' => 'Chill\ReportBundle\Entity\Report')) + ; + + if (count($customFieldsGroups) === 0) { + $output->writeln('There aren\'t any CustomFieldsGroup recorded' + . ' on Reports. Please create at least one.'); + } + + $table = $this->getHelperSet()->get('table'); + $table->setHeaders(array_merge(array('id'), $this->getContainer() + ->getParameter('chill_main.available_languages'))) + ->setRows($this->_prepareRows($customFieldsGroups)); + $table->render($output); + + $customFieldsGroup = $dialog->askAndValidate($output, + "Enter the customfieldGroup's id on which the custom fields " + . "should be added :", + function($answer) use ($customFieldsGroups) { + foreach ($customFieldsGroups as $customFieldsGroup) { + if ($answer == $customFieldsGroup->getId()) { + return $customFieldsGroup; + } + } + + throw new \RunTimeException('The id does not match an existing ' + . 'CustomFieldsGroup'); + } + ); + + if ($input->getOption(self::ARG_DELETE)) { + foreach ($customFieldsGroup->getCustomFields() as $field) { + $em->remove($field); + } + } + + $fieldsInput = $this->_parse($input->getArgument(self::ARG_PATH), + $output); + + $fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output); + + + } + + private function _prepareRows ($customFieldsGroups) + { + $rows = array(); + $languages = $this->getContainer() + ->getParameter('chill_main.available_languages'); + + array_walk($customFieldsGroups, + function(CustomFieldsGroup $customFieldGroup, $key) + use ($languages, &$rows) { + //var_dump($customFieldGroup->getName()); + $row = array( + $customFieldGroup->getId() + ); + foreach ($languages as $lang) { + //todo replace with service to find lang when available + $row[] = (isset($customFieldGroup->getName()[$lang])) ? + $customFieldGroup->getName()[$lang] : + 'Not available in this language'; + } + $rows[] = $row; + } + ); + + return $rows; + } + + private function _parse($path, OutputInterface $output) + { + $parser = new Parser(); + + if (!file_exists($path)) { + throw new \RunTimeException("file does not exist"); + } + + try { + $values = $parser->parse(file_get_contents($path)); + } catch (ParseException $ex) { + throw new \RunTimeException("The yaml file is not valid", 0, $ex); + } + + + return $values; + } + + private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output) + { + $cfProvider = $this->getContainer()->get('chill.custom_field.provider'); + + $em = $this->getContainer()->get('doctrine.orm.entity_manager'); + + $languages = $this->getContainer() + ->getParameter('chill_main.available_languages'); + + foreach($values['fields'] as $slug => $field) { + //check the cf type exists + $cfType = $cfProvider->getCustomFieldByType($field['type']); + if ($cfType === NULL) { + throw new \RunTimeException('the type '.$field['type'].' ' + . 'does not exists'); + } + + $cf = new CustomField(); + $cf->setSlug($slug) + ->setName($field['name']) + ->setOptions(isset($field['options']) ? $field['options'] : array() ) + ->setOrdering($field['ordering']) + ->setType($field['type']) + ->setCustomFieldsGroup($group) + ; + + //add to table + $names = array(); + foreach ($languages as $lang) { + //todo replace with service to find lang when available + $names[] = (isset($cf->getName()[$lang])) ? + $cf->getName()[$lang] : + 'Not available in this language'; + } + + + if ($this->getContainer()->get('validator')->validate($cf)) { + $em->persist($cf); + $output->writeln("Adding Custom Field of type " + .$cf->getType()."\t with slug ".$cf->getSlug(). + "\t and names : ".implode($names, ', ').""); + } else { + throw new \RunTimeException("Error in field ".$slug); + } + + } + + $em->flush(); + } +} From 22c295b51b53cbb8870a957525bf265907ef1311 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 14 Nov 2014 16:49:26 +0100 Subject: [PATCH 046/210] close#326 - When clicking on add a report, we should directly go to the report form if we have only one possible report --- Controller/ReportController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index b09fa416e..f788dd09e 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -73,6 +73,14 @@ class ReportController extends Controller $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') ->findByEntity('Chill\ReportBundle\Entity\Report'); + + if(count($cFGroups) === 1 ){ + return $this->redirect( + $this->generateUrl('report_new', + array('person_id' => $person_id, 'cf_group_id' => $cFGroups[0]->getId()))); + } + + $cFGroupsChoice = array(); foreach ($cFGroups as $cFGroup) { From 349cac4a53e0f10020a5e44100cab79ff9a2590e Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sun, 16 Nov 2014 23:35:35 +0100 Subject: [PATCH 047/210] Do not display (temporary) scope in report ref#300 --- Form/ReportType.php | 2 +- Resources/views/Report/view.html.twig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index 4ee34a48f..0eb17773a 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -39,7 +39,7 @@ class ReportType extends AbstractType ->add('user') ->add('date', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) - ->add('scope') + //->add('scope') ->add('cFData', 'custom_field', array('attr' => array('class' => 'only-label'), 'group' => $options['cFGroup'])) ; diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 5bd7d7ad4..d83196d41 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -30,8 +30,8 @@
{{ 'Personne'|trans }}
{{ entity.person }}
-
{{ 'Scope'|trans }}
-
{{ entity.scope }}
+
{{ 'Date'|trans }}
{{ entity.date|date('d-m-Y') }}
{{ 'Agent'|trans }}
From d86b5d19211e2bab1cf90e5ace5da6bc805baf5d Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sun, 16 Nov 2014 23:40:34 +0100 Subject: [PATCH 048/210] Do not display (temporary) scope in report close#300 --- Resources/config/doctrine/Report.orm.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/doctrine/Report.orm.yml b/Resources/config/doctrine/Report.orm.yml index 5ae4cf3f9..d1dd10031 100644 --- a/Resources/config/doctrine/Report.orm.yml +++ b/Resources/config/doctrine/Report.orm.yml @@ -13,6 +13,7 @@ Chill\ReportBundle\Entity\Report: scope: type: string length: 255 + nullable: true # TO REMOVE IF SCOPE IS USED cFData: type: json_array manyToOne: From c3fc6295cc46c0ad2b3bb722c28932dbf427ff46 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 18 Nov 2014 09:35:06 +0100 Subject: [PATCH 049/210] sticky submit and reset buttons ref #336 --- Controller/ReportController.php | 4 ---- Resources/views/Report/edit.html.twig | 9 +++++++-- Resources/views/Report/new.html.twig | 11 +++++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index f788dd09e..a052f6995 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -192,8 +192,6 @@ class ReportController extends Controller 'cFGroup' => $cFGroup, )); - $form->add('submit', 'submit', array('label' => 'Create')); - return $form; } @@ -264,8 +262,6 @@ class ReportController extends Controller 'cFGroup' => $entity->getCFGroup(), )); - $form->add('submit', 'submit', array('label' => 'Update')); - return $form; } diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index 7779b87a4..10ff09e23 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -21,7 +21,12 @@ {% block title %}{{ 'Edition du rapport' |trans() }}{% endblock title %} {% block personcontent %} + {{ form_start(edit_form) }} - {{ form(edit_form) }} - + {{ form_widget(edit_form) }} +
+ + +
+ {{ form_end(edit_form) }} {% endblock %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index 5277d10f9..b6ac8357b 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -21,5 +21,12 @@ {% block title %}{{ 'Ajout d\' un rapport' |trans() }}{% endblock title %} {% block personcontent %} - {{ form(form) }} -{% endblock %} + {{ form_start(form) }} + + {{ form_widget(form) }} +
+ + +
+ {{ form_end(form) }} +{% endblock %} \ No newline at end of file From eec55b1813c1024b03ba0c13e0b70a65295d9058 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 18 Nov 2014 09:42:58 +0100 Subject: [PATCH 050/210] Impoving form design --- Resources/views/Report/select_report_type.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index 0930bda4e..31ff6c49f 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -26,7 +26,7 @@ {{ form_start(form) }} {{ form_row(form.cFGroup) }} - {{ form_end(form) }} From 92465dd63970bb52ae068a9a07dfd8a59d9b2a88 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 18 Nov 2014 09:45:11 +0100 Subject: [PATCH 051/210] Impoving form design - 2 --- Resources/views/Report/select_report_type.html.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index 31ff6c49f..1bc812f81 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -27,6 +27,7 @@ {{ form_row(form.cFGroup) }} {{ form_end(form) }} From bae32d28cffb35257a233bc7b03dda81509858a2 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 19 Nov 2014 10:33:40 +0100 Subject: [PATCH 052/210] Translation FR --- Form/ReportType.php | 2 +- Resources/translations/messages.fr.yml | 14 ++++++ Resources/views/Report/edit.html.twig | 6 +-- Resources/views/Report/list.html.twig | 46 ------------------- Resources/views/Report/new.html.twig | 6 +-- .../views/Report/select_report_type.html.twig | 7 ++- Resources/views/Report/view.html.twig | 12 ++--- 7 files changed, 30 insertions(+), 63 deletions(-) create mode 100644 Resources/translations/messages.fr.yml delete mode 100644 Resources/views/Report/list.html.twig diff --git a/Form/ReportType.php b/Form/ReportType.php index 0eb17773a..4f7dfd3b3 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -38,7 +38,7 @@ class ReportType extends AbstractType $builder ->add('user') ->add('date', 'date', - array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) + array('required' => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) //->add('scope') ->add('cFData', 'custom_field', array('attr' => array('class' => 'only-label'), 'group' => $options['cFGroup'])) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml new file mode 100644 index 000000000..ce323b21d --- /dev/null +++ b/Resources/translations/messages.fr.yml @@ -0,0 +1,14 @@ +'Report edit': "Edition d'un rapport" +'Save report': "Enregister le rapport" +'Reset report': "Remise à zéro" +'Add a report': "Ajout d'un rapport" +'Add report': 'Ajouter le rapport' +'Create a new report': 'Créer un nouveau rapport' +'Report view': "Détails d'un rapport" +'Update the report': 'Mettre à jour le rapport' +Details: Détails +Person: Personne +Scope: Scope +Date: Date +User: Utilisateur +'Report type': 'Type de rapport' \ No newline at end of file diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index 10ff09e23..6cc18d064 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -18,15 +18,15 @@ {% set activeRouteKey = 'report_select_type' %} -{% block title %}{{ 'Edition du rapport' |trans() }}{% endblock title %} +{% block title %}{{ 'Report edit' |trans }}{% endblock title %} {% block personcontent %} {{ form_start(edit_form) }} {{ form_widget(edit_form) }}
- - + +
{{ form_end(edit_form) }} {% endblock %} diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig deleted file mode 100644 index fcc9eb600..000000000 --- a/Resources/views/Report/list.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} -{% extends "ChillPersonBundle::layout.html.twig" %} - -{% set activeRouteKey = 'report_select_type' %} - -{% block title %}{{ 'List des rapports' |trans() }}{% endblock title %} - -{% block personcontent %} - - - - - - - - - - - - {% for report in reports %} - - - - - - - - {% endfor %} - -
{{ 'Date' | trans }}{{ 'Report Type' | trans }}{{ 'Report Scope' | trans }}
{% if report.date %}{{ report.date|date('d-m-Y') }}{% endif %}{{ report.cFGroup.getName(app.request.locale) }}{{ report.scope }}{{ 'View' | trans }}{{ 'Update' | trans }}
-{% endblock %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index b6ac8357b..67ff20f54 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -18,15 +18,15 @@ {% set activeRouteKey = 'report_select_type' %} -{% block title %}{{ 'Ajout d\' un rapport' |trans() }}{% endblock title %} +{% block title %}{{ 'Add a report'|trans }}{% endblock title %} {% block personcontent %} {{ form_start(form) }} {{ form_widget(form) }}
- - + +
{{ form_end(form) }} {% endblock %} \ No newline at end of file diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index 1bc812f81..581c63e52 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -18,17 +18,16 @@ {% set activeRouteKey = 'report_select_type' %} -{% block title %}{{ 'Ajout d\' un rapport' |trans() }}{% endblock title %} +{% block title %}{{ 'Add a report'|trans() }}{% endblock title %} {% block personcontent %} {{ form_start(form) }} - {{ form_row(form.cFGroup) }} - + {{ form_widget(form.cFGroup) }} {{ form_end(form) }} diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index d83196d41..68594b853 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -18,25 +18,25 @@ {% set activeRouteKey = 'report_select_type' %} -{% block title %}{{ 'Details d\' un rapport' |trans() }}{% endblock title %} +{% block title %}{{ 'Report view' |trans() }}{% endblock title %} {% block personcontent %} - {{ 'Update' | trans }} + {{ 'Update the report'|trans }}

{{ 'Details'|trans }}

-
{{ 'Personne'|trans }}
+
{{ 'Person'|trans }}
{{ entity.person }}
{{ 'Date'|trans }}
{{ entity.date|date('d-m-Y') }}
-
{{ 'Agent'|trans }}
+
{{ 'User'|trans }}
{{ entity.user }}
-
{{ 'Type de rapport'|trans }}
+
{{ 'Report type'|trans }}
{{ entity.cFGroup.getName(app.request.locale) }}
{% for customField in entity.cFGroup.customFields %} @@ -49,6 +49,6 @@ {% endfor %}
- {{ 'Update' | trans }} + {{ 'Update the report' | trans }} {% endblock %} \ No newline at end of file From 140fa5f002137c0bce7e0503bcca213a5cd6c4a2 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 19 Nov 2014 11:14:10 +0100 Subject: [PATCH 053/210] Translation updatng --- Controller/ReportController.php | 27 ++++++++++----- Resources/translations/messages.fr.yml | 15 ++++++++- Resources/views/Report/list.html.twig | 46 ++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 Resources/views/Report/list.html.twig diff --git a/Controller/ReportController.php b/Controller/ReportController.php index a052f6995..510f1d867 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -156,7 +156,7 @@ class ReportController extends Controller ->getFlashBag() ->add('success', $this->get('translator') - ->trans('Report created') + ->trans('Success : report created!') ); return $this->redirect($this->generateUrl('report_view', @@ -166,7 +166,10 @@ class ReportController extends Controller $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $this->get('session') - ->getFlashBag()->add('danger', 'Errors : the report has not been created !'); + ->getFlashBag()->add('danger', + $this->get('translator') + ->trans('The form is not valid. The report has not been created !') + ); return $this->render('ChillReportBundle:Report:new.html.twig', array( 'entity' => $entity, @@ -208,7 +211,8 @@ class ReportController extends Controller $entity = $em->getRepository('ChillReportBundle:Report')->find($report_id); if (!$entity) { - throw $this->createNotFoundException('Unable to find Report entity.'); + throw $this->createNotFoundException( + $this->get('translator')->trans('Unable to find this report.')); } return $this->render('ChillReportBundle:Report:view.html.twig', array( @@ -228,11 +232,13 @@ class ReportController extends Controller $report = $em->getRepository('ChillReportBundle:Report')->find($report_id); if (!$report) { - throw $this->createNotFoundException('Unable to find the report.'); + throw $this->createNotFoundException( + $this->get('translator')->trans('Unable to find this report.')); } if(intval($person_id) !== intval($report->getPerson()->getId())) { - throw new Exception("This is not the report of the person", 1); + throw new Exception( + $this->get('translator')->trans('This is not the report of the person.'), 1); } $person = $report->getPerson(); @@ -276,7 +282,8 @@ class ReportController extends Controller $report = $em->getRepository('ChillReportBundle:Report')->find($report_id); if (!$report) { - throw $this->createNotFoundException('Unable to find the report '.$report_id.'.'); + throw $this->createNotFoundException( + $this->get('translator')->trans('Unable to find this report.')); } $editForm = $this->createEditForm($report, $person_id); @@ -289,7 +296,7 @@ class ReportController extends Controller ->getFlashBag() ->add('success', $this->get('translator') - ->trans('Report updated') + ->trans('Success : report updated!') ); return $this->redirect($this->generateUrl('report_view', @@ -299,7 +306,11 @@ class ReportController extends Controller $errors = $editForm->getErrorsAsString(); $this->get('session') - ->getFlashBag()->add('danger', 'Errors : the report has not been updated !'); + ->getFlashBag() + ->add('danger', + $this->get('translator') + ->trans('The form is not valid. The report has not been updated !') + ); return $this->render('ChillReportBundle:Report:edit.html.twig', array( 'edit_form' => $editForm->createView(), diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index ce323b21d..2fd9a1985 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -6,9 +6,22 @@ 'Create a new report': 'Créer un nouveau rapport' 'Report view': "Détails d'un rapport" 'Update the report': 'Mettre à jour le rapport' +'Report list': 'Liste des rapports' Details: Détails Person: Personne Scope: Scope Date: Date User: Utilisateur -'Report type': 'Type de rapport' \ No newline at end of file +'Report type': 'Type de rapport' +'View the report': "Voir le rapport" +'Update the report': "Mettre à jour le rapport" + +#Flash messages +'Success : report created!': "Succès : le rapport a bien été créé !" +'The form is not valid. The report has not been created !': "Le formulaire comporte des erreurs, le rapport n'a pas été créé" +'Success : report updated!': "Succès : le rapport a bien été mis à jour !" +'The form is not valid. The report has not been updated !': "Le formulaire comporte des erreurs, le rapport n'a pas été mis à jour" + +#Exception messags +'Unable to find this report.': Rapport introuvable. +'This is not the report of the person.': "La personne et le rapport sélectionnés ne sont pas associés" \ No newline at end of file diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig new file mode 100644 index 000000000..c142d7a6d --- /dev/null +++ b/Resources/views/Report/list.html.twig @@ -0,0 +1,46 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} + +{% set activeRouteKey = 'report_select_type' %} + +{% block title %}{{ 'Report list' |trans }}{% endblock title %} + +{% block personcontent %} + + + + + + + + + + + + {% for report in reports %} + + + + + + + + {% endfor %} + +
{{ 'Date' | trans }}{{ 'Report type' | trans }}
{% if report.date %}{{ report.date|date('d-m-Y') }}{% endif %}{{ report.cFGroup.getName(app.request.locale) }}{{ 'View the report' | trans }}{{ 'Update the report' | trans }}
+{% endblock %} From 2b4fd6f793c852513825edc465077822fcc4230a Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 19 Nov 2014 11:43:19 +0100 Subject: [PATCH 054/210] Debug display translation --- Resources/views/Report/edit.html.twig | 4 ++-- Resources/views/Report/new.html.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index 6cc18d064..d6cc88fe4 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -25,8 +25,8 @@ {{ form_widget(edit_form) }}
- - + +
{{ form_end(edit_form) }} {% endblock %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index 67ff20f54..b0fb5cf2a 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -25,8 +25,8 @@ {{ form_widget(form) }}
- - + +
{{ form_end(form) }} {% endblock %} \ No newline at end of file From 2eb2214921ead8a5fd5e62eeecd12a833fd31f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 20 Nov 2014 10:43:32 +0100 Subject: [PATCH 055/210] Move the create fields command to custom fields bundle --- Command/CreateFieldsOnReportsCommand.php | 201 ----------------------- 1 file changed, 201 deletions(-) delete mode 100644 Command/CreateFieldsOnReportsCommand.php diff --git a/Command/CreateFieldsOnReportsCommand.php b/Command/CreateFieldsOnReportsCommand.php deleted file mode 100644 index 29da7f194..000000000 --- a/Command/CreateFieldsOnReportsCommand.php +++ /dev/null @@ -1,201 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -namespace Chill\ReportBundle\Command; - - -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; -use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; -use Symfony\Component\Yaml\Parser; -use Symfony\Component\Yaml\Exception\ParseException; -use Chill\CustomFieldsBundle\Entity\CustomField; - -/** - * - * - * @author Julien Fastré - */ -class CreateFieldsOnReportsCommand extends ContainerAwareCommand -{ - - const ARG_PATH = 'path'; - const ARG_DELETE = 'delete'; - - protected function configure() - { - $this->setName('chill:report:custom_fields:create') - ->setDescription('Associate custom fields on reports. Fields must be ' - . 'described in a yml file.') - ->addArgument(self::ARG_PATH, InputOption::VALUE_REQUIRED, - 'Path to description file') - ->addOption(self::ARG_DELETE, null, InputOption::VALUE_NONE, - 'If set, delete existing fields') - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $dialog = $this->getHelperSet()->get('dialog'); - $em = $this->getContainer() - ->get('doctrine.orm.default_entity_manager'); - - $customFieldsGroups = $em - ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') - ->findBy(array('entity' => 'Chill\ReportBundle\Entity\Report')) - ; - - if (count($customFieldsGroups) === 0) { - $output->writeln('There aren\'t any CustomFieldsGroup recorded' - . ' on Reports. Please create at least one.'); - } - - $table = $this->getHelperSet()->get('table'); - $table->setHeaders(array_merge(array('id'), $this->getContainer() - ->getParameter('chill_main.available_languages'))) - ->setRows($this->_prepareRows($customFieldsGroups)); - $table->render($output); - - $customFieldsGroup = $dialog->askAndValidate($output, - "Enter the customfieldGroup's id on which the custom fields " - . "should be added :", - function($answer) use ($customFieldsGroups) { - foreach ($customFieldsGroups as $customFieldsGroup) { - if ($answer == $customFieldsGroup->getId()) { - return $customFieldsGroup; - } - } - - throw new \RunTimeException('The id does not match an existing ' - . 'CustomFieldsGroup'); - } - ); - - if ($input->getOption(self::ARG_DELETE)) { - foreach ($customFieldsGroup->getCustomFields() as $field) { - $em->remove($field); - } - } - - $fieldsInput = $this->_parse($input->getArgument(self::ARG_PATH), - $output); - - $fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output); - - - } - - private function _prepareRows ($customFieldsGroups) - { - $rows = array(); - $languages = $this->getContainer() - ->getParameter('chill_main.available_languages'); - - array_walk($customFieldsGroups, - function(CustomFieldsGroup $customFieldGroup, $key) - use ($languages, &$rows) { - //var_dump($customFieldGroup->getName()); - $row = array( - $customFieldGroup->getId() - ); - foreach ($languages as $lang) { - //todo replace with service to find lang when available - $row[] = (isset($customFieldGroup->getName()[$lang])) ? - $customFieldGroup->getName()[$lang] : - 'Not available in this language'; - } - $rows[] = $row; - } - ); - - return $rows; - } - - private function _parse($path, OutputInterface $output) - { - $parser = new Parser(); - - if (!file_exists($path)) { - throw new \RunTimeException("file does not exist"); - } - - try { - $values = $parser->parse(file_get_contents($path)); - } catch (ParseException $ex) { - throw new \RunTimeException("The yaml file is not valid", 0, $ex); - } - - - return $values; - } - - private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output) - { - $cfProvider = $this->getContainer()->get('chill.custom_field.provider'); - - $em = $this->getContainer()->get('doctrine.orm.entity_manager'); - - $languages = $this->getContainer() - ->getParameter('chill_main.available_languages'); - - foreach($values['fields'] as $slug => $field) { - //check the cf type exists - $cfType = $cfProvider->getCustomFieldByType($field['type']); - if ($cfType === NULL) { - throw new \RunTimeException('the type '.$field['type'].' ' - . 'does not exists'); - } - - $cf = new CustomField(); - $cf->setSlug($slug) - ->setName($field['name']) - ->setOptions(isset($field['options']) ? $field['options'] : array() ) - ->setOrdering($field['ordering']) - ->setType($field['type']) - ->setCustomFieldsGroup($group) - ; - - //add to table - $names = array(); - foreach ($languages as $lang) { - //todo replace with service to find lang when available - $names[] = (isset($cf->getName()[$lang])) ? - $cf->getName()[$lang] : - 'Not available in this language'; - } - - - if ($this->getContainer()->get('validator')->validate($cf)) { - $em->persist($cf); - $output->writeln("Adding Custom Field of type " - .$cf->getType()."\t with slug ".$cf->getSlug(). - "\t and names : ".implode($names, ', ').""); - } else { - throw new \RunTimeException("Error in field ".$slug); - } - - } - - $em->flush(); - } -} From c16926987619f6c2360777d0151778956e5ed2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 21 Nov 2014 10:58:20 +0100 Subject: [PATCH 056/210] Prevent leaving the new and edit report page without saving. close #319 Code inspired by http://stackoverflow.com/a/21061009/1572236 I think this functionality might be interesting for other forms. Maybe we could abstract them in a twig template to reuse the code (with an 'include' declaration) or add this to all form automatically, by customizing the form_start or form_end function ? --- Resources/views/Report/edit.html.twig | 19 +++++++++++++++++++ Resources/views/Report/new.html.twig | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index d6cc88fe4..7b8380020 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -29,4 +29,23 @@ {{ form_end(edit_form) }} + + {% endblock %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index b0fb5cf2a..00c4a1113 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -29,4 +29,22 @@ {{ form_end(form) }} + {% endblock %} \ No newline at end of file From 20bc5a818a804b8e5155a119657ff257ffd05675 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 25 Nov 2014 15:56:07 +0100 Subject: [PATCH 057/210] class cf-fields for form construction close #363 --- Form/ReportType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index 4f7dfd3b3..6f62cce82 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -41,7 +41,7 @@ class ReportType extends AbstractType array('required' => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) //->add('scope') ->add('cFData', 'custom_field', - array('attr' => array('class' => 'only-label'), 'group' => $options['cFGroup'])) + array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup'])) ; } From de7b9d5ff30ac406f70887278e2cecc6a7dfa7cb Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 25 Nov 2014 17:46:54 +0100 Subject: [PATCH 058/210] More space between the button 'save report' and 'reset form' in report bundle close #354 --- Resources/views/Report/edit.html.twig | 4 ++-- Resources/views/Report/new.html.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index 7b8380020..26b5288a1 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -25,8 +25,8 @@ {{ form_widget(edit_form) }}
- - + +
{{ form_end(edit_form) }} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index 00c4a1113..fbfed9830 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -25,8 +25,8 @@ {{ form_widget(form) }}
- - + +
{{ form_end(form) }} {% endblock %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index fbfed9830..45080a5f0 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -29,22 +29,10 @@ {{ form_end(form) }} - {% endblock %} \ No newline at end of file From 31f76d1339d8bcb89813f539e19f00766b09463d Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 30 Jan 2015 12:28:06 +0100 Subject: [PATCH 079/210] updating js call - close #391 --- Resources/views/Report/edit.html.twig | 2 +- Resources/views/Report/new.html.twig | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index beafc4093..51ecfaaf8 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -33,6 +33,6 @@ {% block js %} {% endblock %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index 45080a5f0..c982a1bf2 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -26,13 +26,12 @@ {{ form_widget(form) }}
-
{{ form_end(form) }} {% endblock %} {% block js %} {% endblock %} \ No newline at end of file From 962dba1bc5cbdeef6a398fac22a0518e5b7cf146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 30 Jan 2015 15:57:24 +0100 Subject: [PATCH 080/210] add doctrine migration to CI refs #402 move webapp directory to App/app, for being consistent with person bundle --- .gitignore | 4 +- .travis.yml | 40 +++++++++---------- Tests/Fixtures/App/{ => app}/AppKernel.php | 4 +- .../App/app/DoctrineMigrations/.gitignore | 2 + .../Fixtures/App/{ => app}/config/config.yml | 0 .../App/{ => app}/config/config_dev.yml | 0 .../App/{ => app}/config/config_test.yml | 0 .../{ => app}/config/parameters.travis.yml | 0 .../App/{ => app}/config/parameters.yml.dist | 0 .../Fixtures/App/{ => app}/config/routing.yml | 0 Tests/Fixtures/App/{ => app}/console | 2 +- Tests/Fixtures/App/config/parameters.yml | 7 ---- Tests/Fixtures/App/web/.gitignore | 2 + composer.json | 16 +++++++- 14 files changed, 44 insertions(+), 33 deletions(-) rename Tests/Fixtures/App/{ => app}/AppKernel.php (93%) create mode 100644 Tests/Fixtures/App/app/DoctrineMigrations/.gitignore rename Tests/Fixtures/App/{ => app}/config/config.yml (100%) rename Tests/Fixtures/App/{ => app}/config/config_dev.yml (100%) rename Tests/Fixtures/App/{ => app}/config/config_test.yml (100%) rename Tests/Fixtures/App/{ => app}/config/parameters.travis.yml (100%) rename Tests/Fixtures/App/{ => app}/config/parameters.yml.dist (100%) rename Tests/Fixtures/App/{ => app}/config/routing.yml (100%) rename Tests/Fixtures/App/{ => app}/console (94%) delete mode 100644 Tests/Fixtures/App/config/parameters.yml create mode 100644 Tests/Fixtures/App/web/.gitignore diff --git a/.gitignore b/.gitignore index 55940e57c..30eab8a47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /vendor/ -composer.lock \ No newline at end of file +composer.lock +Tests/Fixtures/App/app/config/parameters.yml +*~ diff --git a/.travis.yml b/.travis.yml index f45b37f7a..c013209ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,29 @@ language: php php: - - 5.5 - - 5.6 - - hhvm-nightly - +- 5.5 +- 5.6 +- hhvm-nightly matrix: allow_failures: - - php: hhvm-nightly - + - php: hhvm-nightly addons: - postgresql: "9.3" - + postgresql: '9.3' sudo: false - -install: - - composer install --dev - - cp Tests/Fixtures/App/config/parameters.travis.yml Tests/Fixtures/App/config/parameters.yml - +install: +- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH +- composer install --dev --no-interaction +- cp Tests/Fixtures/App/config/parameters.travis.yml Tests/Fixtures/App/config/parameters.yml before_script: - - psql -c 'create database test0;' -U postgres - - php Tests/Fixtures/App/console --env=test cache:warmup -# - php Tests/Fixtures/App/console assets:install Tests/Fixtures/App/web - - php Tests/Fixtures/App/console doctrine:schema:create --env=test --no-interaction - - php Tests/Fixtures/App/console doctrine:fixtures:load --env=test --no-interaction - +- psql -c 'create database test0;' -U postgres +- psql -d test0 -c 'CREATE EXTENSION unaccent;' -U postgres +- php Tests/Fixtures/App/app/console --env=test cache:warmup +- php Tests/Fixtures/App/console assets:install Tests/Fixtures/App/web +- php Tests/Fixtures/App/app/console doctrine:migrations:migrate --no-interaction +- php Tests/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction script: phpunit --coverage-text - notifications: email: - - info@champs-libres.coop + - info@champs-libres.coop +env: + global: + secure: WUAweJ9uyCNVQsv8OOD5jofcxSlRLHbI9HBsDDdSuPVLhCcJCLRdQ312wtn5ckfy3pe+aKaijrM/rhd0NQ6lwCkcYAXcikug9k5tf2BJ0H7AJnqe56/cQSrXvxV8n6L1S2xk4AugG/k6PngZQeca5k/34jJ9ViI06V2+r4UrL7w= diff --git a/Tests/Fixtures/App/AppKernel.php b/Tests/Fixtures/App/app/AppKernel.php similarity index 93% rename from Tests/Fixtures/App/AppKernel.php rename to Tests/Fixtures/App/app/AppKernel.php index 0f63f79bb..c77c6e886 100644 --- a/Tests/Fixtures/App/AppKernel.php +++ b/Tests/Fixtures/App/app/AppKernel.php @@ -2,7 +2,6 @@ use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; -use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle; class AppKernel extends Kernel { @@ -18,7 +17,8 @@ class AppKernel extends Kernel new Chill\PersonBundle\ChillPersonBundle(), new \Symfony\Bundle\AsseticBundle\AsseticBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), - new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle() + new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), + new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle() ); } diff --git a/Tests/Fixtures/App/app/DoctrineMigrations/.gitignore b/Tests/Fixtures/App/app/DoctrineMigrations/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/Tests/Fixtures/App/app/DoctrineMigrations/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/Tests/Fixtures/App/config/config.yml b/Tests/Fixtures/App/app/config/config.yml similarity index 100% rename from Tests/Fixtures/App/config/config.yml rename to Tests/Fixtures/App/app/config/config.yml diff --git a/Tests/Fixtures/App/config/config_dev.yml b/Tests/Fixtures/App/app/config/config_dev.yml similarity index 100% rename from Tests/Fixtures/App/config/config_dev.yml rename to Tests/Fixtures/App/app/config/config_dev.yml diff --git a/Tests/Fixtures/App/config/config_test.yml b/Tests/Fixtures/App/app/config/config_test.yml similarity index 100% rename from Tests/Fixtures/App/config/config_test.yml rename to Tests/Fixtures/App/app/config/config_test.yml diff --git a/Tests/Fixtures/App/config/parameters.travis.yml b/Tests/Fixtures/App/app/config/parameters.travis.yml similarity index 100% rename from Tests/Fixtures/App/config/parameters.travis.yml rename to Tests/Fixtures/App/app/config/parameters.travis.yml diff --git a/Tests/Fixtures/App/config/parameters.yml.dist b/Tests/Fixtures/App/app/config/parameters.yml.dist similarity index 100% rename from Tests/Fixtures/App/config/parameters.yml.dist rename to Tests/Fixtures/App/app/config/parameters.yml.dist diff --git a/Tests/Fixtures/App/config/routing.yml b/Tests/Fixtures/App/app/config/routing.yml similarity index 100% rename from Tests/Fixtures/App/config/routing.yml rename to Tests/Fixtures/App/app/config/routing.yml diff --git a/Tests/Fixtures/App/console b/Tests/Fixtures/App/app/console similarity index 94% rename from Tests/Fixtures/App/console rename to Tests/Fixtures/App/app/console index 2b45f964b..07f73fd68 100644 --- a/Tests/Fixtures/App/console +++ b/Tests/Fixtures/App/app/console @@ -7,7 +7,7 @@ set_time_limit(0); -require_once __DIR__.'/../../bootstrap.php'; +require_once __DIR__.'/../../../bootstrap.php'; require_once __DIR__.'/AppKernel.php'; use Symfony\Bundle\FrameworkBundle\Console\Application; diff --git a/Tests/Fixtures/App/config/parameters.yml b/Tests/Fixtures/App/config/parameters.yml deleted file mode 100644 index b99abd1b9..000000000 --- a/Tests/Fixtures/App/config/parameters.yml +++ /dev/null @@ -1,7 +0,0 @@ -parameters: - database_host: 127.0.0.1 - database_port: 5435 - database_name: chill - database_user: chill - database_password: chill - locale: fr \ No newline at end of file diff --git a/Tests/Fixtures/App/web/.gitignore b/Tests/Fixtures/App/web/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/Tests/Fixtures/App/web/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/composer.json b/composer.json index 3e647e63a..f21b829f5 100644 --- a/composer.json +++ b/composer.json @@ -28,10 +28,24 @@ "doctrine/doctrine-bundle": "~1.2", "chill-project/main": "dev-master@dev", "chill-project/custom-fields": "dev-master@dev", - "chill-project/person": "dev-master@dev" + "chill-project/person": "dev-master@dev", + "champs-libres/composer-bundle-migration": "~1.0", + "doctrine/doctrine-migrations-bundle": "dev-master@dev", + "doctrine/migrations": "~1.0@dev" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "~2.2", "fzaninotto/faker": "~1" + }, + "scripts": { + "post-install-cmd": [ + "ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations" + ], + "post-update-cmd": [ + "ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations" + ] + }, + "extra": { + "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations" } } From 17f2ecd24eb79bfe6477e0d898dfb4ad041df7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 30 Jan 2015 16:04:28 +0100 Subject: [PATCH 081/210] adapt travis installation command to new web app path --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c013209ce..8c39becde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ sudo: false install: - composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH - composer install --dev --no-interaction -- cp Tests/Fixtures/App/config/parameters.travis.yml Tests/Fixtures/App/config/parameters.yml +- cp Tests/Fixtures/App/app/config/parameters.travis.yml Tests/Fixtures/App/app/config/parameters.yml before_script: - psql -c 'create database test0;' -U postgres - psql -d test0 -c 'CREATE EXTENSION unaccent;' -U postgres From 3d5217345b99e6be563514460023f1cd99ee2d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 30 Jan 2015 16:06:51 +0100 Subject: [PATCH 082/210] adapt console path for web assets install --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8c39becde..9fdfae750 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_script: - psql -c 'create database test0;' -U postgres - psql -d test0 -c 'CREATE EXTENSION unaccent;' -U postgres - php Tests/Fixtures/App/app/console --env=test cache:warmup -- php Tests/Fixtures/App/console assets:install Tests/Fixtures/App/web +- php Tests/Fixtures/App/app/console assets:install Tests/Fixtures/App/web - php Tests/Fixtures/App/app/console doctrine:migrations:migrate --no-interaction - php Tests/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction script: phpunit --coverage-text From c986c2e36138bfd1612c68b0d48eb88f55f93a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 30 Jan 2015 16:11:29 +0100 Subject: [PATCH 083/210] adapt new web app path to phpunit.xml.dist --- phpunit.xml.dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6d8da1316..bdf786e24 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,6 +15,6 @@ - + - \ No newline at end of file + From 897a0361a87af7113ad6ff1d5892b5eba52eccc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 5 Feb 2015 21:29:11 +0100 Subject: [PATCH 084/210] fix web app for test and set default parameters/port to 5432 --- Tests/Fixtures/App/app/config/config.yml | 2 +- Tests/Fixtures/App/app/config/parameters.yml.dist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Fixtures/App/app/config/config.yml b/Tests/Fixtures/App/app/config/config.yml index 9ebd4b756..a9cc85293 100644 --- a/Tests/Fixtures/App/app/config/config.yml +++ b/Tests/Fixtures/App/app/config/config.yml @@ -70,4 +70,4 @@ security: access_control: - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/admin, roles: ROLE_ADMIN } - - { path: ^/, roles: ROLE_USER } \ No newline at end of file + - { path: ^/, roles: ROLE_USER } diff --git a/Tests/Fixtures/App/app/config/parameters.yml.dist b/Tests/Fixtures/App/app/config/parameters.yml.dist index 3221c992b..65d50299f 100644 --- a/Tests/Fixtures/App/app/config/parameters.yml.dist +++ b/Tests/Fixtures/App/app/config/parameters.yml.dist @@ -1,6 +1,6 @@ parameters: database_host: 127.0.0.1 - database_port: 5434 + database_port: 5432 database_name: symfony database_user: symfony database_password: symfony From 6ec0892ac6e0cc4e6cb69168d4a0a3a4b07b4052 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 17 Feb 2015 15:11:42 +0100 Subject: [PATCH 085/210] Allowing export for reports --- Controller/ReportController.php | 127 +++++++++++++++--- Resources/config/routing.yml | 16 ++- Resources/views/Report/export.csv.twig | 23 ++++ .../views/Report/select_report_type.html.twig | 2 - .../select_report_type_for_export.html.twig | 33 +++++ 5 files changed, 183 insertions(+), 18 deletions(-) create mode 100644 Resources/views/Report/export.csv.twig create mode 100644 Resources/views/Report/select_report_type_for_export.html.twig diff --git a/Controller/ReportController.php b/Controller/ReportController.php index aa2c7499b..546549d39 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -33,10 +33,12 @@ use Chill\ReportBundle\Form\ReportType; */ class ReportController extends Controller { - /** - * Lists all Report entities. + * List all the report entities for a given person. * + * @param integer $person_id The id of the person. + * @param Request $request The request + * @return Response The web page. */ public function listAction($person_id, Request $request) { @@ -52,9 +54,12 @@ class ReportController extends Controller )); } - /** - * Select the type of the Report + * Display a form for selecting which type of report to add for a given person + * + * @param integer $person_id The id of the person. + * @param Request $request The request + * @return Response The web page. */ public function selectReportTypeAction($person_id, Request $request) { @@ -68,19 +73,15 @@ class ReportController extends Controller $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') ->findByEntity('Chill\ReportBundle\Entity\Report'); - if(count($cFGroups) === 1 ){ return $this->redirect( $this->generateUrl('report_new', array('person_id' => $person_id, 'cf_group_id' => $cFGroups[0]->getId()))); } - $cFGroupsChoice = array(); foreach ($cFGroups as $cFGroup) { @@ -97,6 +98,8 @@ class ReportController extends Controller )) ->getForm(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + return $this->render('ChillReportBundle:Report:select_report_type.html.twig', array( 'form' => $form->createView(), 'person' => $person @@ -104,8 +107,87 @@ class ReportController extends Controller } /** - * Displays a form to create a new Report entity. + * Display a form for selecting which type of report to export + * (a csv file with all the report of this type) * + * @param Request $request The request + * @return Response The web page. + */ + public function selectReportTypeForExportAction(Request $request) + { + $cFGroupId = $request->query->get('cFGroup'); + + if($cFGroupId) { + return $this->redirect( + $this->generateUrl('report_export_list', + array('cf_group_id' => $cFGroupId))); + } + + $em = $this->getDoctrine()->getManager(); + + $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->findByEntity('Chill\ReportBundle\Entity\Report'); + + if(count($cFGroups) === 1 ){ + return $this->redirect( + $this->generateUrl('report_export_list', + array('cf_group_id' => $cFGroups[0]->getId()))); + } + + $cFGroupsChoice = array(); + + foreach ($cFGroups as $cFGroup) { + $cFGroupsChoice[$cFGroup->getId()] = $cFGroup->getName($request->getLocale()); + } + + $form = $this->get('form.factory') + ->createNamedBuilder(null, 'form', null, array( + 'method' => 'GET', + 'csrf_protection' => false + )) + ->add('cFGroup', 'choice', array( + 'choices' => $cFGroupsChoice + )) + ->getForm(); + + return $this->render('ChillReportBundle:Report:select_report_type_for_export.html.twig', array( + 'form' => $form->createView(), + 'layout_name' => "ChillMainBundle::Export/layout.html.twig" + )); + } + + /** + * Return a csv file with all the reports of a given type + * + * @param integer $cf_group_id The id of the report type to export + * @param Request $request The request + * @return A csv file with all the reports of the selected type + */ + public function exportAction($cf_group_id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + + $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); + $reports = $em->getRepository('ChillReportBundle:Report')->findByCFGroup($cFGroup); + + + $response = $this->render('ChillReportBundle:Report:export.csv.twig', array( + 'reports' => $reports, + 'cf_group' => $cFGroup + )); + + $response->headers->set('Content-Type', 'text/csv'); + $response->headers->set('Content-Disposition', 'attachment; filename="export.csv"'); + return $response; + } + + /** + * Display a form for creating a new report for a given person and of a given type + * + * @param integer $person_id The id of the person. + * @param integer $cf_group_id The id of the report type. + * @param Request $request The request + * @return Response The web page. */ public function newAction($person_id, $cf_group_id, Request $request) { @@ -130,8 +212,12 @@ class ReportController extends Controller } /** - * Creates a new Report entity. + * Create a new report for a given person and of a given type * + * @param integer $person_id The id of the person. + * @param integer $cf_group_id The id of the report type. + * @param Request $request The request containing the form data (from the newAction) + * @return Response The web page. */ public function createAction($person_id, $cf_group_id, Request $request) { @@ -183,6 +269,8 @@ class ReportController extends Controller * Creates a form to create a Report entity. * * @param Report $entity The entity + * @param integer $person_id The id of the person. + * @param integer $cf_group_id The id of the report type. * * @return \Symfony\Component\Form\Form The form */ @@ -200,8 +288,11 @@ class ReportController extends Controller } /** - * Finds and displays a Report entity. + * Find and display a report. * + * @param integer $report_id The id of the report. + * @param integer $person_id The id of the person. + * @return Response The web page. */ public function viewAction($report_id, $person_id) { @@ -223,8 +314,11 @@ class ReportController extends Controller } /** - * Displays a form to edit an existing Report entity. + * Display a form to edit an existing Report entity. * + * @param integer $person_id The id of the person. + * @param integer $report_id The id of the report. + * @return Response The web page. */ public function editAction($person_id, $report_id, Request $request) { @@ -255,8 +349,8 @@ class ReportController extends Controller /** * Creates a form to edit a Report entity. * - * @param Report $entity The entity - * + * @param Report $entity The report to edit. + * @param integer $person_id The id of the person. * @return \Symfony\Component\Form\Form The form */ private function createEditForm(Report $entity, $person_id) @@ -273,8 +367,11 @@ class ReportController extends Controller } /** - * Edits an existing Report entity. + * Web page for editing an existing report. * + * @param integer $person_id The id of the person. + * @param integer $report_id The id of the report. + * @return Response The web page. */ public function updateAction($person_id, $report_id, Request $request) { diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 187bc6986..77d410d90 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -34,4 +34,18 @@ report_edit: report_update: path: /{_locale}/person/{person_id}/report/{report_id}/update defaults: { _controller: "ChillReportBundle:Report:update" } - requirements: { _method: post|put } \ No newline at end of file + requirements: { _method: post|put } + +report_export_list: + path: /{_locale}/export/report/cfgroup/{cf_group_id} + defaults: { _controller: "ChillReportBundle:Report:export" } + + +report_export_select_type: + pattern: /{_locale}/export/report/select/type + defaults: {_controller: "ChillReportBundle:Report:selectReportTypeForExport" } + options: + menus: + export: + order: 100 + label: Export reports \ No newline at end of file diff --git a/Resources/views/Report/export.csv.twig b/Resources/views/Report/export.csv.twig new file mode 100644 index 000000000..54548f001 --- /dev/null +++ b/Resources/views/Report/export.csv.twig @@ -0,0 +1,23 @@ +"{{ 'Person'|trans }}",{# +#}"{{ 'Date'|trans }}",{# +#}"{{ 'User'|trans }}",{# +#}"{{ 'Report type'|trans }}",{# +#}{% for customField in cf_group.customFields %}{# + #}"{{ chill_custom_field_label(customField) }}"{% if not loop.last %},{% endif %}{# +#}{% endfor %} + +{% for report in reports %}{# + #}"{{ report.person }}",{# + #}"{{ report.date|localizeddate('long', 'none') }}",{# + #}"{{ report.user }}",{# + #}"{{ report.cFGroup.getName(app.request.locale) }}",{# + #}{% for customField in report.cFGroup.customFields %}{# + #}{% if customField.type == 'title' %}{# + #}""{# + #}{% else %}{# + #}"{{ chill_custom_field_widget(report.cFData , customField, 'csv') }}"{# + #}{% endif %}{# + #}{% if not loop.last %},{% endif %}{# + #}{% endfor %} + +{% endfor %} \ No newline at end of file diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index 581c63e52..b37b1f2ba 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -22,7 +22,6 @@ {% block personcontent %} - {{ form_start(form) }} {{ form_widget(form.cFGroup) }} {{ form_end(form) }} - {% endblock %} \ No newline at end of file diff --git a/Resources/views/Report/select_report_type_for_export.html.twig b/Resources/views/Report/select_report_type_for_export.html.twig new file mode 100644 index 000000000..05a42e954 --- /dev/null +++ b/Resources/views/Report/select_report_type_for_export.html.twig @@ -0,0 +1,33 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillMainBundle::Export/layout.html.twig" %} + +{% set activeRouteKey = 'report_export_list' %} + +{% block title %}{{ 'Reports export'|trans() }}{% endblock title %} + +{% block export_content %} + +{{ form_start(form) }} + {{ form_widget(form.cFGroup) }} + +{{ form_end(form) }} + +{% endblock %} \ No newline at end of file From ba7604a71eb1b8af22fce08f070be75a63356353 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 18 Feb 2015 14:59:07 +0100 Subject: [PATCH 086/210] Adding id - refs #401 --- Resources/views/Report/export.csv.twig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Resources/views/Report/export.csv.twig b/Resources/views/Report/export.csv.twig index 54548f001..dd1083ff8 100644 --- a/Resources/views/Report/export.csv.twig +++ b/Resources/views/Report/export.csv.twig @@ -1,4 +1,5 @@ -"{{ 'Person'|trans }}",{# +"{{ 'Person id'|trans }}",{# +#}"{{ 'Person'|trans }}",{# #}"{{ 'Date'|trans }}",{# #}"{{ 'User'|trans }}",{# #}"{{ 'Report type'|trans }}",{# @@ -7,8 +8,9 @@ #}{% endfor %} {% for report in reports %}{# + #}{{ report.id }},{# #}"{{ report.person }}",{# - #}"{{ report.date|localizeddate('long', 'none') }}",{# + #}"{{ report.date|localizeddate('short', 'none') }}",{# #}"{{ report.user }}",{# #}"{{ report.cFGroup.getName(app.request.locale) }}",{# #}{% for customField in report.cFGroup.customFields %}{# From 5f9a81639c058587241b13bb4f4eeccaa167c9d9 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 18 Feb 2015 15:00:52 +0100 Subject: [PATCH 087/210] Person id -> Report id --- Resources/views/Report/export.csv.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/Report/export.csv.twig b/Resources/views/Report/export.csv.twig index dd1083ff8..fb5b32bdd 100644 --- a/Resources/views/Report/export.csv.twig +++ b/Resources/views/Report/export.csv.twig @@ -1,4 +1,4 @@ -"{{ 'Person id'|trans }}",{# +"{{ 'Report id'|trans }}",{# #}"{{ 'Person'|trans }}",{# #}"{{ 'Date'|trans }}",{# #}"{{ 'User'|trans }}",{# From 80851c4071570b93ee5425c0b2e45ecc19444c95 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 18 Feb 2015 16:28:52 +0100 Subject: [PATCH 088/210] adding person id --- Resources/views/Report/export.csv.twig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Resources/views/Report/export.csv.twig b/Resources/views/Report/export.csv.twig index fb5b32bdd..172e4be5f 100644 --- a/Resources/views/Report/export.csv.twig +++ b/Resources/views/Report/export.csv.twig @@ -1,5 +1,6 @@ "{{ 'Report id'|trans }}",{# #}"{{ 'Person'|trans }}",{# +#}"{{ 'Person id'|trans }}",{# #}"{{ 'Date'|trans }}",{# #}"{{ 'User'|trans }}",{# #}"{{ 'Report type'|trans }}",{# @@ -10,6 +11,7 @@ {% for report in reports %}{# #}{{ report.id }},{# #}"{{ report.person }}",{# + #}"{{ report.person.id }}",{# #}"{{ report.date|localizeddate('short', 'none') }}",{# #}"{{ report.user }}",{# #}"{{ report.cFGroup.getName(app.request.locale) }}",{# From 0cd8b9af3c82f9fbb23382284198e8eb3d6c9943 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 18 Feb 2015 16:30:08 +0100 Subject: [PATCH 089/210] Adding csv_row twig filter --- Resources/views/Report/export.csv.twig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/views/Report/export.csv.twig b/Resources/views/Report/export.csv.twig index 172e4be5f..e54f1cd24 100644 --- a/Resources/views/Report/export.csv.twig +++ b/Resources/views/Report/export.csv.twig @@ -10,11 +10,11 @@ {% for report in reports %}{# #}{{ report.id }},{# - #}"{{ report.person }}",{# - #}"{{ report.person.id }}",{# + #}"{{ report.person|csv_cell }}",{# + #}"{{ report.person.id|csv_cell }}",{# #}"{{ report.date|localizeddate('short', 'none') }}",{# - #}"{{ report.user }}",{# - #}"{{ report.cFGroup.getName(app.request.locale) }}",{# + #}"{{ report.user|csv_cell }}",{# + #}"{{ report.cFGroup.getName(app.request.locale)|csv_cell }}",{# #}{% for customField in report.cFGroup.customFields %}{# #}{% if customField.type == 'title' %}{# #}""{# From ebc5e6ea11a578069323968a86a84b331a36377c Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 20 Feb 2015 17:40:32 +0100 Subject: [PATCH 090/210] Test for reportExport --- Tests/Controller/ReportControllerTest.php | 119 +++++++++++++++++++--- 1 file changed, 105 insertions(+), 14 deletions(-) diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index dacba62e8..d3c833a3a 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -2,12 +2,14 @@ /* * Chill is a software for social workers - * Copyright (C) 2014 Julien Fastré + * + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * , * * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,6 +24,8 @@ namespace Chill\ReportBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\DomCrawler\Form; +use Symfony\Component\DomCrawler\Link; +use Symfony\Component\DomCrawler\Crawler; /** * Test the life cycles of controllers, according to @@ -42,7 +46,7 @@ class ReportControllerTest extends WebTestCase /** * - * @var \Symfony\Component\BrowserKit\Client + * @var \SClientymfony\Component\BrowserKit\ */ private static $client; @@ -68,11 +72,11 @@ class ReportControllerTest extends WebTestCase ->get('doctrine.orm.entity_manager') ->getRepository('ChillMainBundle:User') ->findOneBy(array('username' => "center a_social")); - } /** - * + * Set up the browser to be at a random person general page (/fr/person/%d/general), + * check if there is a menu link for adding a new report and return this link (as producer) * * We assume that : * - we are on a "person" page @@ -81,7 +85,6 @@ class ReportControllerTest extends WebTestCase */ public function testMenu() { - $crawlerPersonPage = static::$client->request('GET', sprintf('/fr/person/%d/general', static::$person->getId())); @@ -106,9 +109,8 @@ class ReportControllerTest extends WebTestCase * @return type * @depends testMenu */ - public function testChooseReportModelPage(\Symfony\Component\DomCrawler\Link $link) - { - + public function testChooseReportModelPage(Link $link) + { // When I click on "adda report" link in menu $crawlerAddAReportPage = static::$client->click($link); @@ -130,8 +132,6 @@ class ReportControllerTest extends WebTestCase $this->assertTrue(static::$client->getResponse()->isRedirect()); return static::$client->followRedirect(); - - } /** @@ -140,7 +140,7 @@ class ReportControllerTest extends WebTestCase * @return type * @depends testChooseReportModelPage */ - public function testNewReportPage(\Symfony\Component\DomCrawler\Crawler $crawlerNewReportPage) + public function testNewReportPage(Crawler $crawlerNewReportPage) { $addForm = $crawlerNewReportPage @@ -355,6 +355,97 @@ class ReportControllerTest extends WebTestCase ->getRepository('ChillReportBundle:Report') ->find($reportId) ->getDate()); + } + + /** + * Test that in the general export page there is an Export reports link + * that leads to export/report/select/type + * + * @return \Symfony\Component\DomCrawler\Link The link to the the + * form use for selecting which type of report to export + */ + public function testLinkToTheExportReport() + { + $crawlerReportExportPage = static::$client->request('GET', '/fr/export'); + if (! static::$client->getResponse()->isSuccessful()) { + var_dump($crawlerReportExportPage->html()); + throw new \RuntimeException('The get request at export page failed'); + } + + $link = $crawlerReportExportPage->selectLink("Export reports")->link(); + $this->assertInstanceOf('Symfony\Component\DomCrawler\Link', $link, + "There is a \"export reports\" link in the export menu"); + + $this->assertContains("export/report/select/type", $link->getUri(), + "The \"export reports\" link in the export menu points to export/report/select/type"); + + return $link; + } + + /** + * Test the export ReportAction : + * - follow the given link ( export/report/select/type ) + * - choose randomly a type of report (CustomFieldsGroup) + * - submit the form + * - check if a csv file is well receiv + * - check if the number of row of the csv file is as expected (number of report of this type + 1) + * + * @depends testLinkToTheExportReport + */ + public function testExportAction(Link $link) + { + $crawlerExportReportPage = static::$client->click($link); + + $form = $crawlerExportReportPage->selectButton("Export this kind of reports")->form(); + + $this->assertInstanceOf('Symfony\Component\DomCrawler\Form', $form, + 'I can see a form with a button "Export this kind of reports" '); + + $this->assertGreaterThan(1, count($form->get(self::REPORT_NAME_FIELD) + ->availableOptionValues()), + "I can choose between report types"); + + $possibleOptionsValue = $form->get(self::REPORT_NAME_FIELD) + ->availableOptionValues(); + + + $cfGroupId = $possibleOptionsValue[array_rand($possibleOptionsValue)]; + + $form->get(self::REPORT_NAME_FIELD)->setValue($cfGroupId); + + static::$client->submit($form); + + $this->assertTrue(static::$client->getResponse()->isRedirect()); + + static::$client->followRedirect(); + + // TO DO CREATE A NEW FUNCTION + + $response = static::$client->getResponse(); + + $this->assertTrue( + strpos($response->headers->get('Content-Type'),'text/csv') !== false, + 'The csv file is well received'); + + echo gettype(static::$kernel->getContainer() + ->get('doctrine.orm.entity_manager')); + + $content = $response->getContent(); + $rows = (explode("\n", $content)); + + $em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager'); + + $cfGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cfGroupId); + $reports = $em->getRepository('ChillReportBundle:Report')->findByCFGroup($cfGroup); + + if($rows[sizeof($rows) -1] == "") { + array_pop($rows); + } + + $this->assertTrue( + sizeof($rows) == (sizeof($reports) + 1), + 'The csv file has a number of row equivalent than the number of reports in the db' + ); } } From ae6553ae0dae49163b5c376e08f382c6fdf05636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 26 Feb 2015 12:15:36 +0100 Subject: [PATCH 091/210] Add timeline to report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #357 and refs #224 Squashed commit of the following: commit 1393a2b283566f428e13160da18487c2a0bbea78 Author: Julien Fastré Date: Thu Feb 26 12:13:56 2015 +0100 add summary_fields in timeline The tests and fixtures are adapted accordingly commit d0374961c2b03a334ff724fbe2995d082d7d7e01 Author: Julien Fastré Date: Thu Feb 26 10:36:56 2015 +0100 fix namespace commit c2d71a17301d923cb20ae295f7d1efef8727a643 Author: Julien Fastré Date: Mon Feb 23 21:59:26 2015 +0100 Improve rendering in person context commit 827d3116a36f8b86bc2dcd79926e42a3d472bb70 Author: Julien Fastré Date: Mon Feb 23 16:34:43 2015 +0100 add test for timeline page commit d93aa527190a6038b4c58dff3af81568c377cd0f Author: Julien Fastré Date: Mon Feb 23 16:34:07 2015 +0100 add message for timeline commit 63de4ddc2c7eca8530b3cc6e122d44840340329d Author: Julien Fastré Date: Mon Feb 23 13:48:32 2015 +0100 create timeline provider --- DataFixtures/ORM/LoadCustomField.php | 2 +- DataFixtures/ORM/LoadCustomFieldsGroup.php | 19 ++- DataFixtures/ORM/LoadReports.php | 2 +- DependencyInjection/ChillReportExtension.php | 14 +- Resources/config/services.yml | 9 +- Resources/translations/messages.fr.yml | 5 +- .../Timeline/report_person_context.html.twig | 23 +++ Tests/Timeline/TimelineProviderTest.php | 157 ++++++++++++++++++ Timeline/TimelineReportProvider.php | 141 ++++++++++++++++ 9 files changed, 362 insertions(+), 10 deletions(-) create mode 100644 Resources/views/Timeline/report_person_context.html.twig create mode 100644 Tests/Timeline/TimelineProviderTest.php create mode 100644 Timeline/TimelineReportProvider.php diff --git a/DataFixtures/ORM/LoadCustomField.php b/DataFixtures/ORM/LoadCustomField.php index 7d45004de..116e2a8e7 100644 --- a/DataFixtures/ORM/LoadCustomField.php +++ b/DataFixtures/ORM/LoadCustomField.php @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -namespace Chill\PersonBundle\DataFixtures\ORM; +namespace Chill\ReportBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; diff --git a/DataFixtures/ORM/LoadCustomFieldsGroup.php b/DataFixtures/ORM/LoadCustomFieldsGroup.php index f926c9df4..fe033069e 100644 --- a/DataFixtures/ORM/LoadCustomFieldsGroup.php +++ b/DataFixtures/ORM/LoadCustomFieldsGroup.php @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -namespace Chill\PersonBundle\DataFixtures\ORM; +namespace Chill\ReportBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; @@ -40,8 +40,13 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt { echo "loading customFieldsGroup...\n"; - $report = $this->createReport($manager, array('fr' => 'Situation de logement')); - $this->addReference('cf_group_report_logement', $report); + $report = $this->createReport($manager, + array('fr' => 'Situation de logement'), + ['summary_fields' => ['has_logement', 'house-desc']]); + $this->addReference( + 'cf_group_report_logement', + $report + ); $report = $this->createReport($manager, array('fr' => 'Alphabétisme')); $this->addReference('cf_group_report_education', $report); @@ -65,13 +70,17 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt * @param array $name * @return CustomFieldsGroup */ - private function createReport(ObjectManager $manager, array $name) + private function createReport( + ObjectManager $manager, + array $name, + array $options = array()) { echo $name['fr']." \n"; $cFGroup = (new CustomFieldsGroup()) ->setName($name) - ->setEntity('Chill\ReportBundle\Entity\Report'); + ->setEntity('Chill\ReportBundle\Entity\Report') + ->setOptions($options); $manager->persist($cFGroup); diff --git a/DataFixtures/ORM/LoadReports.php b/DataFixtures/ORM/LoadReports.php index 8531e0a61..2aba6c286 100644 --- a/DataFixtures/ORM/LoadReports.php +++ b/DataFixtures/ORM/LoadReports.php @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -namespace Chill\PersonBundle\DataFixtures\ORM; +namespace Chill\ReportBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index 1f5d408cf..fb5a285da 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -43,7 +43,19 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac $container->prependExtensionConfig('chill_custom_fields', array('customizables_entities' => array( - array('class' => 'Chill\ReportBundle\Entity\Report', 'name' => 'ReportEntity') + array( + 'class' => 'Chill\ReportBundle\Entity\Report', + 'name' => 'ReportEntity', + 'options' => array( + 'summary_fields' => array( + 'form_type' => 'custom_fields_group_linked_custom_fields', + 'form_options' => + [ + 'multiple' => true, + 'expanded' => false + ] + ) + )) ) ) ); diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 4c06c3b79..f5305da04 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -11,4 +11,11 @@ services: calls: - [setContainer, ["@service_container"]] tags: - - { name: chill.search, alias: 'report' } \ No newline at end of file + - { name: chill.search, alias: 'report' } + + chill.report.timeline: + class: Chill\ReportBundle\Timeline\TimelineReportProvider + arguments: + - '@doctrine.orm.entity_manager' + tags: + - { name: chill.timeline, context: 'person' } \ No newline at end of file diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 3b1940502..4b5e591c1 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -32,4 +32,7 @@ User: Utilisateur 'You may not set a date argument and a date in default': Vous avez introduit deux dates, l'une avec l'argument date et l'autre en zone de recherche par défaut. Merci d'indiquer l'un ou l'autre 'You must provide either a date:YYYY-mm-dd argument or a YYYY-mm-dd default search': Merci d'indiquer soit un argument date:YYYY-mm-dd, soit une date dans la recherche par défaut. 'Reports search results': Recherche dans les rapports -'%total% reports matching the search "%pattern%"': '{0} Aucun rapport ne correspond à la recherche "%pattern%" | {1} Un rapport correspond à la recherche "%pattern%" | ]1,Inf]%total% rapports correspondent à la recherche "%pattern%"' \ No newline at end of file +'%total% reports matching the search "%pattern%"': '{0} Aucun rapport ne correspond à la recherche "%pattern%" | {1} Un rapport correspond à la recherche "%pattern%" | ]1,Inf]%total% rapports correspondent à la recherche "%pattern%"' + +#timeline +'%user% has filled a %report_label% report on %date%': %user% a ajouté un rapport '%report_label%' le %date% \ No newline at end of file diff --git a/Resources/views/Timeline/report_person_context.html.twig b/Resources/views/Timeline/report_person_context.html.twig new file mode 100644 index 000000000..d19559632 --- /dev/null +++ b/Resources/views/Timeline/report_person_context.html.twig @@ -0,0 +1,23 @@ +
+
+ {{ '%user% has filled a %report_label% report on %date%'|trans( + { + '%user%' : user, + '%report_label%': report.CFGroup.name|localize_translatable_string, + '%date%' : report.date|localizeddate('long', 'none') } + ) }} {{ 'View the report'|trans }} +
+ {% if custom_fields_in_summary|length > 0 %} +
+ {% for field in custom_fields_in_summary %} + {% if field.type == 'title' %} + {{ chill_custom_field_widget(report.cFData, field) }} + {% else %} +
{{ chill_custom_field_label(field) }}
+
{{ chill_custom_field_widget(report.cFData, field) }}
+ {% endif %} + {% endfor %} +
+ {% endif %} +
\ No newline at end of file diff --git a/Tests/Timeline/TimelineProviderTest.php b/Tests/Timeline/TimelineProviderTest.php new file mode 100644 index 000000000..bf18a3eab --- /dev/null +++ b/Tests/Timeline/TimelineProviderTest.php @@ -0,0 +1,157 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ReportBundle\Tests\Timeline; + +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Chill\PersonBundle\Entity\Person; +use Chill\ReportBundle\Entity\Report; +use Chill\MainBundle\Tests\TestHelper as MainTestHelper; + +/** + * Test a report is shown into timeline + * + * @author Julien Fastré + * @author Champs Libres + */ +class TimelineProviderTest extends WebTestCase +{ + + /** + * + * @var \Doctrine\ORM\EntityManager + */ + private static $em; + + /** + * + * @var Person + */ + private $person; + + /** + * + * @var Report + */ + private $report; + + /** + * Create a person with a report associated with the person + */ + public function setUp() + { + static::bootKernel(); + + static::$em = static::$kernel->getContainer() + ->get('doctrine.orm.entity_manager'); + + $this->person = (new Person(new \DateTime('2015-05-01'))) + ->setGenre(Person::GENRE_WOMAN) + ->setFirstName('Nelson') + ->setLastName('Mandela'); + static::$em->persist($this->person); + + $this->report = (new Report) + ->setUser(static::$em->getRepository('ChillMainBundle:User') + ->findOneByUsername('chill b_social')) + ->setDate(new \DateTime('2015-05-02')) + ->setPerson($this->person) + ->setCFGroup($this->getHousingCustomFieldsGroup()) + ->setCFData(['has_logement' => 'own_house', + 'house-desc' => 'blah blah']); + + static::$em->persist($this->report); + + + + static::$em->flush(); + + } + + /** + * Test that a report is shown in timeline + */ + public function testTimelineReport() + { + $client = static::createClient(array(), + MainTestHelper::getAuthenticatedClientOptions() + ); + + $crawler = $client->request('GET', '/fr/person/'.$this->person->getId() + .'/timeline'); + + $this->assertTrue($client->getResponse()->isSuccessful(), + 'The page timeline is loaded successfully'); + $this->assertContains('a ajouté un rapport', $crawler->text(), + 'the page contains the text "a publié un rapport"'); + } + + public function testTimelineReportWithSummaryField() + { + //load the page + $client = static::createClient(array(), + MainTestHelper::getAuthenticatedClientOptions() + ); + + $crawler = $client->request('GET', '/fr/person/'.$this->person->getId() + .'/timeline'); + + //performs tests + $this->assertTrue($client->getResponse()->isSuccessful(), + 'The page timeline is loaded successfully'); + $this->assertGreaterThan(0, $crawler->filter('.report .summary') + ->count(), + 'the page contains a .report .summary element'); + $this->assertContains('blah blah', $crawler->filter('.report .summary') + ->text(), + 'the page contains the text "blah blah"'); + $this->assertContains('Propriétaire', $crawler->filter('.report .summary') + ->text(), + 'the page contains the mention "Propriétaire"'); + } + + /** + * get a random custom fields group + * + * @return \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup + */ + private function getHousingCustomFieldsGroup() + { + $groups = static::$em + ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->findAll(); + + foreach ($groups as $group) { + if ($group->getName()['fr'] === 'Situation de logement') { + return $group; + } + } + + return $groups[rand(0, count($groups) -1)]; + } + + + + public function tearDown() + { + //static::$em->remove($this->person); + //static::$em->remove($this->report); + } +} diff --git a/Timeline/TimelineReportProvider.php b/Timeline/TimelineReportProvider.php new file mode 100644 index 000000000..c9138c9d4 --- /dev/null +++ b/Timeline/TimelineReportProvider.php @@ -0,0 +1,141 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ReportBundle\Timeline; + +use Chill\MainBundle\Timeline\TimelineProviderInterface; +use Doctrine\ORM\EntityManager; + +/** + * Provide report for inclusion in timeline + * + * @author Julien Fastré + * @author Champs Libres + */ +class TimelineReportProvider implements TimelineProviderInterface +{ + + /** + * + * @var EntityManager + */ + protected $em; + + public function __construct(EntityManager $em) + { + $this->em = $em; + } + + /** + * + * {@inheritDoc} + */ + public function fetchQuery($context, array $args) + { + $this->checkContext($context); + + $metadata = $this->em->getClassMetadata('ChillReportBundle:Report'); + + return array( + 'id' => $metadata->getColumnName('id'), + 'type' => 'report', + 'date' => $metadata->getColumnName('date'), + 'FROM' => $metadata->getTableName(), + 'WHERE' => sprintf('%s = %d', + $metadata + ->getAssociationMapping('person')['joinColumns'][0]['name'], + $args['person']->getId()) + ); + } + + /** + * + * {@inheritDoc} + */ + public function getEntities(array $ids) + { + $reports = $this->em->getRepository('ChillReportBundle:Report') + ->findBy(array('id' => $ids)); + + $result = array(); + foreach($reports as $report) { + $result[$report->getId()] = $report; + } + + return $result; + } + + /** + * + * {@inheritDoc} + */ + public function getEntityTemplate($entity, $context, array $args) + { + $this->checkContext($context); + + //gather all custom fields which should appears in summary + $customFieldsInSummary = array(); + if (array_key_exists('summary_fields', $entity->getCFGroup()->getOptions())) { + + foreach ($entity->getCFGroup()->getCustomFields() as $customField) { + if (in_array($customField->getSlug(), + $entity->getCFGroup()->getOptions()['summary_fields'])) { + $customFieldsInSummary[] = $customField; + } + } + } + + + + return array( + 'template' => 'ChillReportBundle:Timeline:report_person_context.html.twig', + 'template_data' => array( + 'report' => $entity, + 'custom_fields_in_summary' => $customFieldsInSummary, + 'person' => $args['person'], + 'user' => $entity->getUser() + ) + ); + } + + /** + * + * {@inheritDoc} + */ + public function supportsType($type) + { + return $type === 'report'; + } + + /** + * check if the context is supported + * + * @param string $context + * @throws \LogicException if the context is not supported + */ + private function checkContext($context) + { + if ($context !== 'person') { + throw new \LogicException("The context '$context' is not " + . "supported. Currently only 'person' is supported"); + } + } + +} From 3f92b6bf4df76b693048d95640192d6d6f94bfad Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 27 Feb 2015 12:58:27 +0100 Subject: [PATCH 092/210] adding utf8 format --- Controller/ReportController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 546549d39..a01e005ee 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -176,7 +176,7 @@ class ReportController extends Controller 'cf_group' => $cFGroup )); - $response->headers->set('Content-Type', 'text/csv'); + $response->headers->set('Content-Type', 'text/csv; charset=utf-8'); $response->headers->set('Content-Disposition', 'attachment; filename="export.csv"'); return $response; } From 26ed31e89ed2b570b21e3a065790c07dd0649355 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 27 Feb 2015 12:58:50 +0100 Subject: [PATCH 093/210] Better line return --- Resources/views/Report/export.csv.twig | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Resources/views/Report/export.csv.twig b/Resources/views/Report/export.csv.twig index e54f1cd24..6a13f61d6 100644 --- a/Resources/views/Report/export.csv.twig +++ b/Resources/views/Report/export.csv.twig @@ -6,9 +6,10 @@ #}"{{ 'Report type'|trans }}",{# #}{% for customField in cf_group.customFields %}{# #}"{{ chill_custom_field_label(customField) }}"{% if not loop.last %},{% endif %}{# -#}{% endfor %} +#}{% endfor %}{# -{% for report in reports %}{# +#}{{ '\r\n'|raw }}{# +#}{% for report in reports %}{# #}{{ report.id }},{# #}"{{ report.person|csv_cell }}",{# #}"{{ report.person.id|csv_cell }}",{# @@ -22,6 +23,7 @@ #}"{{ chill_custom_field_widget(report.cFData , customField, 'csv') }}"{# #}{% endif %}{# #}{% if not loop.last %},{% endif %}{# - #}{% endfor %} - -{% endfor %} \ No newline at end of file + #}{% endfor %}{# + + #}{{ '\r\n'|raw }}{# +#}{% endfor %} \ No newline at end of file From 9b867ea0e09f96851c1adc610ebd140e4622b120 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 27 Feb 2015 14:01:30 +0100 Subject: [PATCH 094/210] Improving Test refs #401 --- Tests/Controller/ReportControllerTest.php | 65 ++++++++++++++++------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index d3c833a3a..dde5b0881 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -52,10 +52,19 @@ class ReportControllerTest extends WebTestCase private static $user; + /** + * + * @var \Doctrine\ORM\EntityManagerInterface + */ + private static $em; + public static function setUpBeforeClass() { static::bootKernel(); + static::$em = static::$kernel->getContainer() + ->get('doctrine.orm.entity_manager'); + //get a random person $persons = static::$kernel->getContainer() ->get('doctrine.orm.entity_manager') @@ -111,7 +120,7 @@ class ReportControllerTest extends WebTestCase */ public function testChooseReportModelPage(Link $link) { - // When I click on "adda report" link in menu + // When I click on "add a report" link in menu $crawlerAddAReportPage = static::$client->click($link); $form = $crawlerAddAReportPage->selectButton("Créer un nouveau rapport")->form(); @@ -384,16 +393,15 @@ class ReportControllerTest extends WebTestCase } /** - * Test the export ReportAction : + * Test the export form for selecting the type of report to export : * - follow the given link ( export/report/select/type ) * - choose randomly a type of report (CustomFieldsGroup) * - submit the form - * - check if a csv file is well receiv - * - check if the number of row of the csv file is as expected (number of report of this type + 1) * + * @return Integer The id of the type of report selected (CFGroup) * @depends testLinkToTheExportReport */ - public function testExportAction(Link $link) + public function testFormForExportAction(Link $link) { $crawlerExportReportPage = static::$client->click($link); @@ -419,32 +427,53 @@ class ReportControllerTest extends WebTestCase $this->assertTrue(static::$client->getResponse()->isRedirect()); static::$client->followRedirect(); - - // TO DO CREATE A NEW FUNCTION - + + return $cfGroupId; + } + + /** + * Test the output of the export action : + * - check if a csv file is well received + * - check if the csv is well formated (if each row has the same number of + * cells) + * - check if the number of data rows (not the header) of the csv file is + * as expected (number of report of this type) + * + * @param Int The id of the type of report selected (CFGroup) + * @depends testFormForExportAction + */ + public function testCSVExportAction($cfGroupId) + { $response = static::$client->getResponse(); $this->assertTrue( strpos($response->headers->get('Content-Type'),'text/csv') !== false, 'The csv file is well received'); - - echo gettype(static::$kernel->getContainer() - ->get('doctrine.orm.entity_manager')); $content = $response->getContent(); - $rows = (explode("\n", $content)); + $rows = str_getcsv($content, "\n"); + + $headerRow = array_pop($rows); + $header = str_getcsv($headerRow); + $headerSize = sizeof($header); + $numberOfRows = 0; - $em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager'); + foreach ($rows as $row) { + $rowContent = str_getcsv($row); - $cfGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cfGroupId); - $reports = $em->getRepository('ChillReportBundle:Report')->findByCFGroup($cfGroup); + $this->assertTrue( + sizeof($rowContent) == $headerSize, + 'Each row of the csv contains the good number of elements (' + . 'regarding to the first row'); - if($rows[sizeof($rows) -1] == "") { - array_pop($rows); + $numberOfRows ++; } + $cfGroup = static::$em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cfGroupId); + $reports = static::$em->getRepository('ChillReportBundle:Report')->findByCFGroup($cfGroup); + $this->assertTrue( - sizeof($rows) == (sizeof($reports) + 1), + $numberOfRows == sizeof($reports), 'The csv file has a number of row equivalent than the number of reports in the db' ); } From df9fb881b174d438e4be20b4a8bf8c734ebc1e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 27 Feb 2015 17:42:31 +0100 Subject: [PATCH 095/210] add title to report box in timeline --- Resources/views/Timeline/report_person_context.html.twig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Resources/views/Timeline/report_person_context.html.twig b/Resources/views/Timeline/report_person_context.html.twig index d19559632..8dc83776f 100644 --- a/Resources/views/Timeline/report_person_context.html.twig +++ b/Resources/views/Timeline/report_person_context.html.twig @@ -1,4 +1,5 @@
+

{{ 'Report'|trans }}

{{ '%user% has filled a %report_label% report on %date%'|trans( { @@ -10,6 +11,8 @@
{% if custom_fields_in_summary|length > 0 %}
+
+
{% for field in custom_fields_in_summary %} {% if field.type == 'title' %} {{ chill_custom_field_widget(report.cFData, field) }} @@ -18,6 +21,7 @@
{{ chill_custom_field_widget(report.cFData, field) }}
{% endif %} {% endfor %} +
{% endif %}
\ No newline at end of file From 38d9832b720014c2abceffb99c070fd9fbd268df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 31 Mar 2015 21:30:34 +0200 Subject: [PATCH 096/210] Fix syntax - namespace should be first declaration https://insight.sensiolabs.com/projects/6031863a-10a3-44d5-891d-ac6dac2ed65a/analyses/1?status=violations#239680027 --- Entity/Report.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Entity/Report.php b/Entity/Report.php index 117956cd1..04a47a150 100644 --- a/Entity/Report.php +++ b/Entity/Report.php @@ -1,9 +1,5 @@ @@ -24,6 +20,10 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; namespace Chill\ReportBundle\Entity; +use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Entity\Person; +use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; + /** * Report */ @@ -218,4 +218,4 @@ class Report { return $this->cFGroup; } -} \ No newline at end of file +} From ee205d33863d7c0d19af53e8d7f6a5356e68ca4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 31 Mar 2015 21:32:03 +0200 Subject: [PATCH 097/210] set namespace/use declaration on exception highlighted by https://insight.sensiolabs.com/projects/6031863a-10a3-44d5-891d-ac6dac2ed65a/analyses/1?status=violations#239680028 --- Controller/ReportController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index a01e005ee..aab1b341a 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -332,7 +332,7 @@ class ReportController extends Controller } if(intval($person_id) !== intval($report->getPerson()->getId())) { - throw new Exception( + throw new \Exception( $this->get('translator')->trans('This is not the report of the person.'), 1); } From 6ac74823895792f4804a90b24a642c2785c519e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 5 Jun 2015 10:59:19 +0200 Subject: [PATCH 098/210] switch to symfony 2.7 [ci skip] --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index f21b829f5..df02bd3e5 100644 --- a/composer.json +++ b/composer.json @@ -19,16 +19,16 @@ "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", - "symfony/framework-bundle": "2.5.*", - "symfony/yaml": "2.5.*", - "symfony/symfony": "2.5.*", + "symfony/framework-bundle": "~2.7", + "symfony/yaml": "~2.7", + "symfony/symfony": "~2.7", "doctrine/dbal": "~2.5", "doctrine/orm": "~2.4", "doctrine/common": "~2.4", "doctrine/doctrine-bundle": "~1.2", - "chill-project/main": "dev-master@dev", - "chill-project/custom-fields": "dev-master@dev", - "chill-project/person": "dev-master@dev", + "chill-project/main": "dev-add_acl@dev", + "chill-project/custom-fields": "dev-add_acl@dev", + "chill-project/person": "dev-add_acl@dev", "champs-libres/composer-bundle-migration": "~1.0", "doctrine/doctrine-migrations-bundle": "dev-master@dev", "doctrine/migrations": "~1.0@dev" From 39197d2ae69e708ff1876dde82dbaf9a310eebfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 5 Jun 2015 11:42:09 +0200 Subject: [PATCH 099/210] fix deprecation of pattern in routing pattern => path in routing --- Resources/config/routing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 77d410d90..356734bd7 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,5 +1,5 @@ report_select_type: - pattern: /{_locale}/person/{person_id}/report/select/type/for/creation + path: /{_locale}/person/{person_id}/report/select/type/for/creation defaults: { _controller: "ChillReportBundle:Report:selectReportType" } options: menus: @@ -42,7 +42,7 @@ report_export_list: report_export_select_type: - pattern: /{_locale}/export/report/select/type + path: /{_locale}/export/report/select/type defaults: {_controller: "ChillReportBundle:Report:selectReportTypeForExport" } options: menus: From 3d7069011d1f747c6cad9951ebfd40db89ffb6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 5 Jun 2015 12:58:20 +0200 Subject: [PATCH 100/210] remove deprecation warning from phpunit --- phpunit.xml.dist | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index bdf786e24..a2fcbb39e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,4 +1,9 @@ - + + + ./Tests @@ -16,5 +21,6 @@ + From 064ccfba3f2d0ebb4d6572f3771d248e68bc5107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 8 Jun 2015 00:31:02 +0200 Subject: [PATCH 101/210] adapt loadReport to new user refs --- DataFixtures/ORM/LoadReports.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DataFixtures/ORM/LoadReports.php b/DataFixtures/ORM/LoadReports.php index 2aba6c286..ed284051b 100644 --- a/DataFixtures/ORM/LoadReports.php +++ b/DataFixtures/ORM/LoadReports.php @@ -122,8 +122,9 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co private function fillReport(Report $report) { //setUser + $usernameRef = array_rand(LoadUsers::$refs); $report->setUser( - $this->getReference(LoadUsers::$refs[array_rand(LoadUsers::$refs)]) + $this->getReference($usernameRef) ); //set date if null From efa2f001c7b0c6e240267952fc43801657badc48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 19 Jun 2015 22:36:00 +0200 Subject: [PATCH 102/210] add person.center to timeline tests --- Tests/Timeline/TimelineProviderTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tests/Timeline/TimelineProviderTest.php b/Tests/Timeline/TimelineProviderTest.php index bf18a3eab..904136770 100644 --- a/Tests/Timeline/TimelineProviderTest.php +++ b/Tests/Timeline/TimelineProviderTest.php @@ -62,10 +62,14 @@ class TimelineProviderTest extends WebTestCase static::$em = static::$kernel->getContainer() ->get('doctrine.orm.entity_manager'); + $center = static::$em->getRepository('ChillMainBundle:Center') + ->findOneBy(array('name' => 'Center A')); + $this->person = (new Person(new \DateTime('2015-05-01'))) ->setGenre(Person::GENRE_WOMAN) ->setFirstName('Nelson') - ->setLastName('Mandela'); + ->setLastName('Mandela') + ->setCenter($center); static::$em->persist($this->person); $this->report = (new Report) From 1c3c3b14ab572fd887b327624b7428a617edcba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 22 Jun 2015 22:38:13 +0200 Subject: [PATCH 103/210] mark some tests as skipped Some tests raise an error which seems being a bug into symfony. Mark test as skipped before further inquery. --- Tests/Controller/ReportControllerTest.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index dde5b0881..177640735 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -223,11 +223,17 @@ class ReportControllerTest extends WebTestCase */ public function testNullDate(Form $form) { + $this->markTestSkipped("This test raise an error since symfony 2.7. " + . "The user is not correctly reloaded from database."); $filledForm = $this->fillCorrectForm($form); $filledForm->get('chill_reportbundle_report[date]')->setValue(''); - $crawler = static::$client->submit($filledForm); - + $client = static::createClient(array(), array( + 'PHP_AUTH_USER' => 'center a_social', + 'PHP_AUTH_PW' => 'password', + )); + $crawler = $client->submit($filledForm); + var_dump($crawler->text()); $this->assertFalse(static::$client->getResponse()->isRedirect()); $this->assertGreaterThan(0, $crawler->filter('.error')->count()); } @@ -240,6 +246,8 @@ class ReportControllerTest extends WebTestCase */ public function testInvalidDate(Form $form) { + $this->markTestSkipped("This test raise an error since symfony 2.7. " + . "The user is not correctly reloaded from database."); $filledForm = $this->fillCorrectForm($form); $filledForm->get('chill_reportbundle_report[date]')->setValue('invalid date value'); @@ -276,9 +284,11 @@ class ReportControllerTest extends WebTestCase */ public function testValidCreate(Form $addForm) { + $this->markTestSkipped("This test raise an error since symfony 2.7. " + . "The user is not correctly reloaded from database."); $filledForm = $this->fillCorrectForm($addForm); $c = static::$client->submit($filledForm); - + var_dump($c->text()); $this->assertTrue(static::$client->getResponse()->isRedirect(), "The next page is a redirection to the new report's view page"); static::$client->followRedirect(); From eb066b86aa892e53e6c7fa351b0fcbbbbf58c76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 22 Jun 2015 23:45:59 +0200 Subject: [PATCH 104/210] add foreign key from report to scope --- Entity/Report.php | 18 ++++++-- Resources/config/doctrine/Report.orm.yml | 6 +-- .../migrations/Version20150622233319.php | 42 +++++++++++++++++++ 3 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 Resources/migrations/Version20150622233319.php diff --git a/Entity/Report.php b/Entity/Report.php index 117956cd1..728f65897 100644 --- a/Entity/Report.php +++ b/Entity/Report.php @@ -24,10 +24,14 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; namespace Chill\ReportBundle\Entity; +use Chill\MainBundle\Entity\HasCenterInterface; +use Chill\MainBundle\Entity\HasScopeInterface; +use Chill\MainBundle\Entity\Scope; + /** * Report */ -class Report +class Report implements HasCenterInterface, HasScopeInterface { /** * @var integer @@ -50,7 +54,7 @@ class Report private $date; /** - * @var string + * @var Scope */ private $scope; @@ -154,7 +158,7 @@ class Report * * @return Report */ - public function setScope($scope) + public function setScope(Scope $scope) { $this->scope = $scope; @@ -164,7 +168,7 @@ class Report /** * Get scope * - * @return string + * @return Scope */ public function getScope() { @@ -218,4 +222,10 @@ class Report { return $this->cFGroup; } + + public function getCenter() + { + return $this->person->getCenter(); + } + } \ No newline at end of file diff --git a/Resources/config/doctrine/Report.orm.yml b/Resources/config/doctrine/Report.orm.yml index d1dd10031..bf4b5c7de 100644 --- a/Resources/config/doctrine/Report.orm.yml +++ b/Resources/config/doctrine/Report.orm.yml @@ -10,10 +10,6 @@ Chill\ReportBundle\Entity\Report: fields: date: type: datetime - scope: - type: string - length: 255 - nullable: true # TO REMOVE IF SCOPE IS USED cFData: type: json_array manyToOne: @@ -21,6 +17,8 @@ Chill\ReportBundle\Entity\Report: targetEntity: Chill\MainBundle\Entity\User person: targetEntity: Chill\PersonBundle\Entity\Person + scope: + targetEntity: Chill\MainBundle\Entity\Scope cFGroup: targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldsGroup lifecycleCallbacks: { } \ No newline at end of file diff --git a/Resources/migrations/Version20150622233319.php b/Resources/migrations/Version20150622233319.php new file mode 100644 index 000000000..3ef33fbef --- /dev/null +++ b/Resources/migrations/Version20150622233319.php @@ -0,0 +1,42 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', + 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE report ADD scope_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE report DROP scope'); //before this migration, scope was never used + $this->addSql('ALTER TABLE report ADD CONSTRAINT FK_report_scope ' + . 'FOREIGN KEY (scope_id) ' + . 'REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_report_scope ON report (scope_id)'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', + 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE Report DROP CONSTRAINT FK_C38372B2682B5931'); + $this->addSql('DROP INDEX IDX_C38372B2682B5931'); + $this->addSql('ALTER TABLE Report ADD scope VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE Report DROP scope_id'); + } +} From b7a17af6829ffd5627b2b881e5f5711ce723ccbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 22 Jun 2015 23:46:36 +0200 Subject: [PATCH 105/210] git status add role hierarchy --- DependencyInjection/ChillReportExtension.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index fb5a285da..2df5a38ae 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -76,6 +76,16 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac ) )); } + + protected function prependRoleHierarchy(ContainerBuilder $container) + { + $container->prependExtensionConfig('security', array( + 'role_hierarchy' => array( + 'CHILL_REPORT_UPDATE' => array('CHILL_REPORT_SEE'), + 'CHILL_REPORT_CREATE' => array('CHILL_REPORT_SEE') + ) + )); + } /** * {@inheritdoc} @@ -86,5 +96,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac { $this->declareReportAsCustomizable($container); $this->declareRouting($container); + $this->prependRoleHierarchy($container); } + } From 4d2b3f2a6175ad2c84b519e2410b9fb07fd9bb59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 22 Jun 2015 23:47:01 +0200 Subject: [PATCH 106/210] add report voter + tests --- Resources/config/services.yml | 9 +- Security/Authorization/ReportVoter.php | 66 ++++++ .../Authorization/ReportVoterTest.php | 193 ++++++++++++++++++ 3 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 Security/Authorization/ReportVoter.php create mode 100644 Tests/Security/Authorization/ReportVoterTest.php diff --git a/Resources/config/services.yml b/Resources/config/services.yml index f5305da04..774d6e677 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -18,4 +18,11 @@ services: arguments: - '@doctrine.orm.entity_manager' tags: - - { name: chill.timeline, context: 'person' } \ No newline at end of file + - { name: chill.timeline, context: 'person' } + + chill.report.security.authorization.report_voter: + class: Chill\ReportBundle\Security\Authorization\ReportVoter + arguments: + - "@chill.main.security.authorization.helper" + tags: + - { name: security.voter } \ No newline at end of file diff --git a/Security/Authorization/ReportVoter.php b/Security/Authorization/ReportVoter.php new file mode 100644 index 000000000..e363923df --- /dev/null +++ b/Security/Authorization/ReportVoter.php @@ -0,0 +1,66 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ReportBundle\Security\Authorization; + +use Chill\MainBundle\Security\Authorization\AbstractChillVoter; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; + +/** + * + * + * @author Julien Fastré + */ +class ReportVoter extends AbstractChillVoter +{ + const CREATE = 'CHILL_REPORT_CREATE'; + const SEE = 'CHILL_REPORT_SEE'; + const UPDATE = 'CHILL_REPORT_UPDATE'; + + /** + * + * @var AuthorizationHelper + */ + protected $helper; + + public function __construct(AuthorizationHelper $helper) + { + $this->helper = $helper; + } + + protected function getSupportedAttributes() + { + return array(self::CREATE, self::SEE, self::UPDATE); + } + + protected function getSupportedClasses() + { + return array('Chill\ReportBundle\Entity\Report'); + } + + protected function isGranted($attribute, $report, $user = null) + { + if (! $user instanceof \Chill\MainBundle\Entity\User){ + + return false; + } + + return $this->helper->userHasAccess($user, $report, $attribute); + } +} diff --git a/Tests/Security/Authorization/ReportVoterTest.php b/Tests/Security/Authorization/ReportVoterTest.php new file mode 100644 index 000000000..8fa450fb0 --- /dev/null +++ b/Tests/Security/Authorization/ReportVoterTest.php @@ -0,0 +1,193 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ReportBundle\Tests\Security\Authorization; + +use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Chill\MainBundle\Test\PrepareUserTrait; +use Chill\MainBundle\Test\PrepareCenterTrait; +use Chill\MainBundle\Test\PrepareScopeTrait; +use Chill\ReportBundle\Entity\Report; +use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; +use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Entity\Center; +use Chill\PersonBundle\Entity\Person; + +/** + * + * + * @author Julien Fastré + */ +class ReportVoterTest extends KernelTestCase +{ + + use PrepareUserTrait, PrepareCenterTrait, PrepareScopeTrait; + + /** + * + * @var \Chill\ReportBundle\Security\Authorization\ReportVoter + */ + protected $voter; + + /** + * + * @var \Prophecy\Prophet + */ + protected $prophet; + + public static function setUpBeforeClass() + { + + } + + public function setUp() + { + static::bootKernel(); + $this->voter = static::$kernel->getContainer() + ->get('chill.report.security.authorization.report_voter'); + $this->prophet = new \Prophecy\Prophet(); + } + + /** + * @dataProvider dataProvider + * @param type $expectedResult + * @param Report $report + * @param User $user + * @param type $action + * @param type $message + */ + public function testAccess($expectedResult, Report $report, $action, + $message, User $user = null) + { + $token = $this->prepareToken($user); + $result = $this->voter->vote($token, $report, [$action]); + $this->assertEquals($expectedResult, $result, $message); + } + + /** + * prepare a person + * + * The only properties set is the center, others properties are ignored. + * + * @param Center $center + * @return Person + */ + protected function preparePerson(Center $center) + { + return (new Person()) + ->setCenter($center) + ; + } + + /** + * prepare a token interface with correct rights + * + * if $permissions = null, user will be null (no user associated with token + * + * @param User $user + * @return \Symfony\Component\Security\Core\Authentication\Token\TokenInterface + */ + protected function prepareToken(User $user = null) + { + $token = $this->prophet->prophesize(); + $token + ->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + if ($user === NULL) { + $token->getUser()->willReturn(null); + } else { + $token->getUser()->willReturn($user); + } + + return $token->reveal(); + } + + public function dataProvider() + { + $centerA = $this->prepareCenter(1, 'center A'); + $centerB = $this->prepareCenter(2, 'center B'); + $scopeA = $this->prepareScope(1, 'scope default'); + $scopeB = $this->prepareScope(2, 'scope B'); + $scopeC = $this->prepareScope(3, 'scope C'); + + $userA = $this->prepareUser(array( + array( + 'center' => $centerA, + 'permissionsGroup' => array( + ['scope' => $scopeB, 'role' => 'CHILL_REPORT_SEE'], + ['scope' => $scopeA, 'role' => 'CHILL_REPORT_UPDATE'] + ) + ), + array( + 'center' => $centerB, + 'permissionsGroup' => array( + ['scope' => $scopeA, 'role' => 'CHILL_REPORT_SEE'], + ) + ) + + )); + + $reportA = (new Report) + ->setScope($scopeA) + ->setPerson($this->preparePerson($centerA)) + ; + $reportB = (new Report()) + ->setScope($scopeB) + ->setPerson($this->preparePerson($centerA)) + ; + $reportC = (new Report()) + ->setScope($scopeC) + ->setPerson($this->preparePerson($centerB)) + ; + + + return array( + array( + VoterInterface::ACCESS_DENIED, + $reportA, + 'CHILL_REPORT_SEE', + "assert is denied to a null user", + null + ), + array( + VoterInterface::ACCESS_GRANTED, + $reportA, + 'CHILL_REPORT_SEE', + "assert access is granted to a user with inheritance UPDATE > SEE", + $userA + ), + array( + VoterInterface::ACCESS_GRANTED, + $reportB, + 'CHILL_REPORT_SEE', + "assert access is granted to a user without inheritance", + $userA + ), + array( + VoterInterface::ACCESS_DENIED, + $reportC, + 'CHILL_REPORT_SEE', + 'assert access is denied to a report', + $userA + ) + ); + + } + + +} From c75ba202b4ce781fcc5345202f9b6626c43fe955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 23 Jun 2015 21:36:02 +0200 Subject: [PATCH 107/210] add scope type to report [transfer] [ci skip] --- Controller/ReportController.php | 25 +++++++++++++++---------- Form/ReportType.php | 11 ++++++++--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index a01e005ee..3c267734a 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -23,7 +23,7 @@ namespace Chill\ReportBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; - +use Chill\PersonBundle\Entity\Person; use Chill\ReportBundle\Entity\Report; use Chill\ReportBundle\Form\ReportType; @@ -224,16 +224,21 @@ class ReportController extends Controller $em = $this->getDoctrine()->getManager(); $entity = new Report(); - $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); + $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->find($cf_group_id); + + $person = $em->getRepository('ChillPersonBundle:Person') + ->find($person_id); + + if($person === NULL OR $cFGroup === NULL) { + throw $this->createNotFoundException(); + } - $form = $this->createCreateForm($entity, $person_id, $cFGroup); + $form = $this->createCreateForm($entity, $person, $cFGroup); $form->handleRequest($request); if ($form->isValid()) { - $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); $entity->setCFGroup($cFGroup); - - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $entity->setPerson($person); $em->persist($entity); @@ -250,7 +255,6 @@ class ReportController extends Controller array('person_id' => $person_id,'report_id' => $entity->getId()))); } - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $this->get('session') ->getFlashBag()->add('danger', @@ -274,11 +278,12 @@ class ReportController extends Controller * * @return \Symfony\Component\Form\Form The form */ - private function createCreateForm(Report $entity, $person_id, $cFGroup) + private function createCreateForm(Report $entity, Person $person, $cFGroup) { $form = $this->createForm(new ReportType(), $entity, array( 'action' => $this->generateUrl('report_create', - array('person_id' => $person_id, 'cf_group_id' => $cFGroup->getId())), + array('person_id' => $person->getId(), + 'cf_group_id' => $cFGroup->getId())), 'method' => 'POST', 'em' => $this->getDoctrine()->getManager(), 'cFGroup' => $cFGroup, @@ -302,7 +307,7 @@ class ReportController extends Controller $entity = $em->getRepository('ChillReportBundle:Report')->find($report_id); - if (!$entity) { + if (!$entity OR !$person) { throw $this->createNotFoundException( $this->get('translator')->trans('Unable to find this report.')); } diff --git a/Form/ReportType.php b/Form/ReportType.php index 6f62cce82..6910751b4 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -39,9 +39,10 @@ class ReportType extends AbstractType ->add('user') ->add('date', 'date', array('required' => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) - //->add('scope') + ->add('scope', 'scope') ->add('cFData', 'custom_field', - array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup'])) + array('attr' => array('class' => 'cf-fields'), + 'group' => $options['cFGroup'])) ; } @@ -57,11 +58,15 @@ class ReportType extends AbstractType $resolver->setRequired(array( 'em', 'cFGroup', + 'role', + 'center' )); $resolver->setAllowedTypes(array( 'em' => 'Doctrine\Common\Persistence\ObjectManager', - 'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup' + 'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup', + 'role' => 'Symfony\Component\Security\Core\Role\Role', + 'center' => 'Chill\MainBundle\Entity\Center' )); } From a938ce50907039d60395d4d3ef7ce0c33b7e533d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 Jun 2015 00:00:11 +0200 Subject: [PATCH 108/210] add report ACL fixtures --- DataFixtures/ORM/LoadReportACL.php | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 DataFixtures/ORM/LoadReportACL.php diff --git a/DataFixtures/ORM/LoadReportACL.php b/DataFixtures/ORM/LoadReportACL.php new file mode 100644 index 000000000..0cec37b42 --- /dev/null +++ b/DataFixtures/ORM/LoadReportACL.php @@ -0,0 +1,82 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ReportBundle\DataFixtures\ORM; + +use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Common\Persistence\ObjectManager; +use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; +use Chill\MainBundle\Entity\RoleScope; +use Chill\MainBundle\DataFixtures\ORM\LoadScopes; + +/** + * Add a role CHILL_REPORT_UPDATE & CHILL_REPORT_CREATE for all groups except administrative, + * and a role CHILL_REPORT_SEE for administrative + * + * @author Julien Fastré + */ +class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface +{ + public function getOrder() + { + return 14999; + } + + + public function load(ObjectManager $manager) + { + foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { + $permissionsGroup = $this->getReference($permissionsGroupRef); + foreach (LoadScopes::$references as $scopeRef){ + $scope = $this->getReference($scopeRef); + //create permission group + switch ($permissionsGroup->getName()) { + case 'social': + if ($scope->getName()['en'] === 'administrative') { + continue; // we do not want any power on administrative + } + case 'administrative': + case 'direction': + if (in_array($scope->getName()['en'], array('administrative', 'social'))) { + continue; // we do not want any power on social or administrative + } + } + + printf("Adding CHILL_REPORT_UPDATE & CHILL_REPORT_CREATE to %s " + . "permission group, scope '%s' \n", + $permissionsGroup->getName(), $scope->getName()['en']); + $roleScopeUpdate = (new RoleScope()) + ->setRole('CHILL_REPORT_UPDATE') + ->setScope($scope); + $permissionsGroup->addRoleScope($roleScopeUpdate); + $roleScopeCreate = (new RoleScope()) + ->setRole('CHILL_REPORT_CREATE') + ->setScope($scope); + $permissionsGroup->addRoleScope($roleScopeCreate); + $manager->persist($roleScopeUpdate); + $manager->persist($roleScopeCreate); + } + + } + + $manager->flush(); + } + +} From ec70067429b93ecc63cf0b0307e3ec1a6c499135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 Jun 2015 00:00:42 +0200 Subject: [PATCH 109/210] add scope to form "new" report [ci skip] --- Controller/ReportController.php | 20 ++++++++++++++++---- Form/ReportType.php | 25 +++++++++++-------------- Resources/config/services.yml | 11 ++++++++++- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 3c267734a..97ac0bbb3 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -26,6 +26,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Chill\PersonBundle\Entity\Person; use Chill\ReportBundle\Entity\Report; use Chill\ReportBundle\Form\ReportType; +use Symfony\Component\Security\Core\Role\Role; /** * Report controller. @@ -194,15 +195,25 @@ class ReportController extends Controller $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $cFGroup = $em + ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->find($cf_group_id); + + if ($person === NULL) { + throw $this->createNotFoundException("Person not found"); + } + + if ($cFGroup === NULL){ + throw $this->createNotFoundException("custom fields group not found"); + } $entity = new Report(); $entity->setUser($this->get('security.context')->getToken()->getUser()); $entity->setDate(new \DateTime('now')); - $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); $entity->setCFGroup($cFGroup); - $form = $this->createCreateForm($entity, $person_id, $cFGroup); + $form = $this->createCreateForm($entity, $person, $cFGroup); return $this->render('ChillReportBundle:Report:new.html.twig', array( 'entity' => $entity, @@ -280,13 +291,14 @@ class ReportController extends Controller */ private function createCreateForm(Report $entity, Person $person, $cFGroup) { - $form = $this->createForm(new ReportType(), $entity, array( + $form = $this->createForm('chill_reportbundle_report', $entity, array( 'action' => $this->generateUrl('report_create', array('person_id' => $person->getId(), 'cf_group_id' => $cFGroup->getId())), 'method' => 'POST', - 'em' => $this->getDoctrine()->getManager(), 'cFGroup' => $cFGroup, + 'role' => new Role('CHILL_REPORT_CREATE'), + 'center' => $person->getCenter() )); return $form; diff --git a/Form/ReportType.php b/Form/ReportType.php index 6910751b4..2d64a9010 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -21,52 +21,49 @@ namespace Chill\ReportBundle\Form; -use Symfony\Component\Form\AbstractType; +use Chill\MainBundle\Form\Type\AbstractHasScopeType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; -class ReportType extends AbstractType -{ +class ReportType extends AbstractHasScopeType +{ /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { - $entityManager = $options['em']; - $builder ->add('user') ->add('date', 'date', array('required' => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) - ->add('scope', 'scope') ->add('cFData', 'custom_field', array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup'])) ; + + $this->appendScopeChoices($builder, $options); } /** * @param OptionsResolverInterface $resolver */ - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { + parent::configureOptions($resolver); + $resolver->setDefaults(array( 'data_class' => 'Chill\ReportBundle\Entity\Report' )); $resolver->setRequired(array( - 'em', 'cFGroup', - 'role', - 'center' )); $resolver->setAllowedTypes(array( - 'em' => 'Doctrine\Common\Persistence\ObjectManager', 'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup', - 'role' => 'Symfony\Component\Security\Core\Role\Role', - 'center' => 'Chill\MainBundle\Entity\Center' )); } diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 774d6e677..f076d43a8 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -25,4 +25,13 @@ services: arguments: - "@chill.main.security.authorization.helper" tags: - - { name: security.voter } \ No newline at end of file + - { name: security.voter } + + chill.report.form.report_type: + class: Chill\ReportBundle\Form\ReportType + arguments: + - "@chill.main.security.authorization.helper" + - "@security.token_storage" + - "@chill.main.helper.translatable_string" + tags: + - { name: form.type, alias: chill_reportbundle_report } \ No newline at end of file From adf1a5eb2c15b966222b0b443ded27e092a3a444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 Jun 2015 00:15:16 +0200 Subject: [PATCH 110/210] fix syntax in Report class --- Entity/Report.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Entity/Report.php b/Entity/Report.php index 728f65897..494c309bb 100644 --- a/Entity/Report.php +++ b/Entity/Report.php @@ -1,8 +1,5 @@ user = $user; @@ -106,11 +106,11 @@ class Report implements HasCenterInterface, HasScopeInterface /** * Set person * - * @param \Person $person + * @param Person $person * * @return Report */ - public function setPerson($person) + public function setPerson(Person $person) { $this->person = $person; @@ -120,7 +120,7 @@ class Report implements HasCenterInterface, HasScopeInterface /** * Get person * - * @return \Person + * @return Person */ public function getPerson() { @@ -182,7 +182,7 @@ class Report implements HasCenterInterface, HasScopeInterface * * @return Report */ - public function setCFData($cFData) + public function setCFData(array $cFData) { $this->cFData = $cFData; @@ -202,11 +202,11 @@ class Report implements HasCenterInterface, HasScopeInterface /** * Set cFGroup * - * @param \CustomFieldsGroup $cFGroup + * @param CustomFieldsGroup $cFGroup * * @return Report */ - public function setCFGroup($cFGroup) + public function setCFGroup(CustomFieldsGroup $cFGroup) { $this->cFGroup = $cFGroup; @@ -216,7 +216,7 @@ class Report implements HasCenterInterface, HasScopeInterface /** * Get cFGroup * - * @return \CustomFieldsGroup + * @return CustomFieldsGroup */ public function getCFGroup() { From b264ceeaa8a2bb994e839cf072b79e327858811b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 Jun 2015 00:17:54 +0200 Subject: [PATCH 111/210] improve php syntax --- Controller/ReportController.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 97ac0bbb3..787ca45f8 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -241,7 +241,7 @@ class ReportController extends Controller $person = $em->getRepository('ChillPersonBundle:Person') ->find($person_id); - if($person === NULL OR $cFGroup === NULL) { + if($person === NULL || $cFGroup === NULL) { throw $this->createNotFoundException(); } @@ -319,7 +319,7 @@ class ReportController extends Controller $entity = $em->getRepository('ChillReportBundle:Report')->find($report_id); - if (!$entity OR !$person) { + if (!$entity || !$person) { throw $this->createNotFoundException( $this->get('translator')->trans('Unable to find this report.')); } @@ -349,7 +349,7 @@ class ReportController extends Controller } if(intval($person_id) !== intval($report->getPerson()->getId())) { - throw new Exception( + throw new \RuntimeException( $this->get('translator')->trans('This is not the report of the person.'), 1); } @@ -418,8 +418,6 @@ class ReportController extends Controller array('person_id' => $report->getPerson()->getId(), 'report_id' => $report_id))); } - $errors = $editForm->getErrorsAsString(); - $this->get('session') ->getFlashBag() ->add('danger', From 4a6dee763f30b963aac154f4481ea85e436e6236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 Jun 2015 00:18:35 +0200 Subject: [PATCH 112/210] remove unused use statement --- Form/ReportType.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index 2d64a9010..5c138094f 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -24,8 +24,6 @@ namespace Chill\ReportBundle\Form; use Chill\MainBundle\Form\Type\AbstractHasScopeType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; class ReportType extends AbstractHasScopeType { From 7cf41d9c9dbccfa94b6f8651eef524caf277a850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 Jun 2015 00:30:20 +0200 Subject: [PATCH 113/210] add newline (\n) at the end of file --- Entity/Report.php | 2 +- README.md | 2 +- Resources/config/doctrine/Report.orm.yml | 3 ++- Resources/config/routing.yml | 3 ++- Resources/config/services.yml | 3 ++- Resources/translations/messages.fr.yml | 2 +- Resources/translations/messages.nl.yml | 2 +- Resources/views/Report/export.csv.twig | 2 +- Resources/views/Report/new.html.twig | 2 +- Resources/views/Report/select_report_type.html.twig | 2 +- Resources/views/Report/select_report_type_for_export.html.twig | 2 +- Resources/views/Report/view.html.twig | 2 +- Resources/views/Search/results.html.twig | 2 +- Resources/views/Timeline/report_person_context.html.twig | 2 +- 14 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Entity/Report.php b/Entity/Report.php index 494c309bb..d3088800a 100644 --- a/Entity/Report.php +++ b/Entity/Report.php @@ -228,4 +228,4 @@ class Report implements HasCenterInterface, HasScopeInterface return $this->person->getCenter(); } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 8df9a4bd3..e6d3b1a95 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ ChillReport The bundle for reports -[![Build Status](https://travis-ci.org/Chill-project/Report.png)](http://travis-ci.org/#!/Chill-project/Report.png) \ No newline at end of file +[![Build Status](https://travis-ci.org/Chill-project/Report.png)](http://travis-ci.org/#!/Chill-project/Report.png) diff --git a/Resources/config/doctrine/Report.orm.yml b/Resources/config/doctrine/Report.orm.yml index bf4b5c7de..7632a282d 100644 --- a/Resources/config/doctrine/Report.orm.yml +++ b/Resources/config/doctrine/Report.orm.yml @@ -21,4 +21,5 @@ Chill\ReportBundle\Entity\Report: targetEntity: Chill\MainBundle\Entity\Scope cFGroup: targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldsGroup - lifecycleCallbacks: { } \ No newline at end of file + lifecycleCallbacks: { } + \ No newline at end of file diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 356734bd7..96a053bac 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -48,4 +48,5 @@ report_export_select_type: menus: export: order: 100 - label: Export reports \ No newline at end of file + label: Export reports + \ No newline at end of file diff --git a/Resources/config/services.yml b/Resources/config/services.yml index f076d43a8..c81adc2e6 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -34,4 +34,5 @@ services: - "@security.token_storage" - "@chill.main.helper.translatable_string" tags: - - { name: form.type, alias: chill_reportbundle_report } \ No newline at end of file + - { name: form.type, alias: chill_reportbundle_report } + \ No newline at end of file diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 4b5e591c1..97569e262 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -35,4 +35,4 @@ User: Utilisateur '%total% reports matching the search "%pattern%"': '{0} Aucun rapport ne correspond à la recherche "%pattern%" | {1} Un rapport correspond à la recherche "%pattern%" | ]1,Inf]%total% rapports correspondent à la recherche "%pattern%"' #timeline -'%user% has filled a %report_label% report on %date%': %user% a ajouté un rapport '%report_label%' le %date% \ No newline at end of file +'%user% has filled a %report_label% report on %date%': %user% a ajouté un rapport '%report_label%' le %date% diff --git a/Resources/translations/messages.nl.yml b/Resources/translations/messages.nl.yml index 5ce488d3f..046931812 100644 --- a/Resources/translations/messages.nl.yml +++ b/Resources/translations/messages.nl.yml @@ -26,4 +26,4 @@ User: Gebruiker 'Unable to find this report.': Dossier is onvindbaar 'This is not the report of the person.': "Dit is niet het dossier van deze person" -'You are going to leave a page with unsubmitted data. Are you sure you want to leave ?': 'U bent aan te vertrekken een pagina die veranderdt datas behoudt. Bent u er zeker van dat u wil vertrekken ?' \ No newline at end of file +'You are going to leave a page with unsubmitted data. Are you sure you want to leave ?': 'U bent aan te vertrekken een pagina die veranderdt datas behoudt. Bent u er zeker van dat u wil vertrekken ?' diff --git a/Resources/views/Report/export.csv.twig b/Resources/views/Report/export.csv.twig index 6a13f61d6..90217f1db 100644 --- a/Resources/views/Report/export.csv.twig +++ b/Resources/views/Report/export.csv.twig @@ -26,4 +26,4 @@ #}{% endfor %}{# #}{{ '\r\n'|raw }}{# -#}{% endfor %} \ No newline at end of file +#}{% endfor %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index c982a1bf2..ca1955301 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -34,4 +34,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index b37b1f2ba..52432883b 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -30,4 +30,4 @@ {{ form_end(form) }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/Resources/views/Report/select_report_type_for_export.html.twig b/Resources/views/Report/select_report_type_for_export.html.twig index 05a42e954..55d0667e2 100644 --- a/Resources/views/Report/select_report_type_for_export.html.twig +++ b/Resources/views/Report/select_report_type_for_export.html.twig @@ -30,4 +30,4 @@ {{ form_end(form) }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 25a705339..bbce26cc0 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -51,4 +51,4 @@ {{ 'Update the report' | trans }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/Resources/views/Search/results.html.twig b/Resources/views/Search/results.html.twig index f122e3e4d..acb887a46 100644 --- a/Resources/views/Search/results.html.twig +++ b/Resources/views/Search/results.html.twig @@ -42,4 +42,4 @@ {% endfor %} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/Resources/views/Timeline/report_person_context.html.twig b/Resources/views/Timeline/report_person_context.html.twig index 8dc83776f..8ac8432f1 100644 --- a/Resources/views/Timeline/report_person_context.html.twig +++ b/Resources/views/Timeline/report_person_context.html.twig @@ -24,4 +24,4 @@
{% endif %} - \ No newline at end of file + From 8445e81d44da1d12ae82a24e14ce4136cadd8a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 Jun 2015 22:32:28 +0200 Subject: [PATCH 114/210] refactor: move scope field to trait [ci skip] as we know tests are failing --- Form/ReportType.php | 57 ++++++++++++++++++++++++--- Resources/config/services.yml | 1 + Resources/views/Report/view.html.twig | 4 +- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index 5c138094f..aa56daa80 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -21,12 +21,54 @@ namespace Chill\ReportBundle\Form; -use Chill\MainBundle\Form\Type\AbstractHasScopeType; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\MainBundle\Form\Type\AppendScopeChoiceTypeTrait; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Doctrine\Common\Persistence\ObjectManager; -class ReportType extends AbstractHasScopeType +class ReportType extends AbstractType { + use AppendScopeChoiceTypeTrait; + + /** + * + * @var AuthorizationHelper + */ + protected $authorizationHelper; + + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + /** + * + * @var \Doctrine\Common\Persistence\ObjectManager + */ + protected $om; + + /** + * + * @var \Chill\MainBundle\Entity\User + */ + protected $user; + + public function __construct(AuthorizationHelper $helper, + TokenStorageInterface $tokenStorage, + TranslatableStringHelper $translatableStringHelper, + ObjectManager $om) + { + $this->authorizationHelper = $helper; + $this->user = $tokenStorage->getToken()->getUser(); + $this->translatableStringHelper = $translatableStringHelper; + $this->om = $om; + } + /** * @param FormBuilderInterface $builder * @param array $options @@ -42,16 +84,17 @@ class ReportType extends AbstractHasScopeType 'group' => $options['cFGroup'])) ; - $this->appendScopeChoices($builder, $options); + $this->appendScopeChoices($builder, $options['role'], $options['center'], + $this->user, $this->authorizationHelper, + $this->translatableStringHelper, + $this->om); } /** * @param OptionsResolverInterface $resolver */ public function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - + { $resolver->setDefaults(array( 'data_class' => 'Chill\ReportBundle\Entity\Report' )); @@ -63,6 +106,8 @@ class ReportType extends AbstractHasScopeType $resolver->setAllowedTypes(array( 'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup', )); + + $this->appendScopeChoicesOptions($resolver); } /** diff --git a/Resources/config/services.yml b/Resources/config/services.yml index c81adc2e6..35fbf3b27 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -33,6 +33,7 @@ services: - "@chill.main.security.authorization.helper" - "@security.token_storage" - "@chill.main.helper.translatable_string" + - "@doctrine.orm.entity_manager" tags: - { name: form.type, alias: chill_reportbundle_report } \ No newline at end of file diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index bbce26cc0..0d964007a 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -30,8 +30,8 @@
{{ 'Person'|trans }}
{{ entity.person }}
- +
{{ 'Scope'|trans }}
+
{{ entity.scope.name|localize_translatable_string }}
{{ 'Date'|trans }}
{{ entity.date|localizeddate('long', 'none') }}
{{ 'User'|trans }}
From c10445c8a40d65d63c85ee033a959f5221d14ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 25 Jun 2015 22:42:19 +0200 Subject: [PATCH 115/210] allow report edit w/ scope + add deny statements [ci skip] --- Controller/ReportController.php | 38 ++++++++++++++++++++------- Resources/views/Report/list.html.twig | 4 +-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 787ca45f8..b628808f9 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -45,9 +45,15 @@ class ReportController extends Controller { $em = $this->getDoctrine()->getManager(); - $reports = $em->getRepository('ChillReportBundle:Report')->findByPerson($person_id); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + + $reachableScopes = $this->get('chill.main.security.authorization.helper') + ->getReachableScopes($this->getUser(), new Role('CHILL_REPORT_SEE'), + $person->getCenter()); + $reports = $em->getRepository('ChillReportBundle:Report') + ->findBy(array('person' => $person, 'scope' => $reachableScopes)); return $this->render('ChillReportBundle:Report:list.html.twig', array( 'reports' => $reports, @@ -194,7 +200,7 @@ class ReportController extends Controller { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $cFGroup = $em ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') ->find($cf_group_id); @@ -203,6 +209,8 @@ class ReportController extends Controller throw $this->createNotFoundException("Person not found"); } + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + if ($cFGroup === NULL){ throw $this->createNotFoundException("custom fields group not found"); } @@ -244,6 +252,8 @@ class ReportController extends Controller if($person === NULL || $cFGroup === NULL) { throw $this->createNotFoundException(); } + + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); $form = $this->createCreateForm($entity, $person, $cFGroup); $form->handleRequest($request); @@ -252,6 +262,8 @@ class ReportController extends Controller $entity->setCFGroup($cFGroup); $entity->setPerson($person); + $this->denyAccessUnlessGranted('CHILL_REPORT_CREATE', $entity); + $em->persist($entity); $em->flush(); @@ -323,6 +335,8 @@ class ReportController extends Controller throw $this->createNotFoundException( $this->get('translator')->trans('Unable to find this report.')); } + + $this->denyAccessUnlessGranted('CHILL_REPORT_SEE', $entity); return $this->render('ChillReportBundle:Report:view.html.twig', array( 'entity' => $entity, @@ -352,10 +366,12 @@ class ReportController extends Controller throw new \RuntimeException( $this->get('translator')->trans('This is not the report of the person.'), 1); } + + $this->denyAccessUnlessGranted('CHILL_REPORT_UPDATE', $report); $person = $report->getPerson(); - $editForm = $this->createEditForm($report, $person->getId()); + $editForm = $this->createEditForm($report); return $this->render('ChillReportBundle:Report:edit.html.twig', array( 'edit_form' => $editForm->createView(), @@ -370,14 +386,16 @@ class ReportController extends Controller * @param integer $person_id The id of the person. * @return \Symfony\Component\Form\Form The form */ - private function createEditForm(Report $entity, $person_id) + private function createEditForm(Report $entity) { - $form = $this->createForm(new ReportType(), $entity, array( + $form = $this->createForm('chill_reportbundle_report', $entity, array( 'action' => $this->generateUrl('report_update', - array('person_id' => $person_id, 'report_id' => $entity->getId())), + array('person_id' => $entity->getPerson()->getId(), + 'report_id' => $entity->getId())), 'method' => 'PUT', - 'em' => $this->getDoctrine()->getManager(), 'cFGroup' => $entity->getCFGroup(), + 'role' => new Role('CHILL_REPORT_UPDATE'), + 'center' => $entity->getPerson()->getCenter() )); return $form; @@ -400,8 +418,10 @@ class ReportController extends Controller throw $this->createNotFoundException( $this->get('translator')->trans('Unable to find this report.')); } + + $this->denyAccessUnlessGranted('CHILL_REPORT_UPDATE', $report); - $editForm = $this->createEditForm($report, $person_id); + $editForm = $this->createEditForm($report); $editForm->handleRequest($request); if ($editForm->isValid()) { diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index 9495c920f..56b9e0faf 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -26,7 +26,7 @@ {{ 'Date' | trans }} {{ 'Report type' | trans }} - + {{ 'Report scope' | trans }} @@ -36,7 +36,7 @@ {% if report.date %}{{ report.date|localizeddate('long', 'none') }}{% endif %} {{ report.cFGroup.getName(app.request.locale) }} - + {{ report.scope.name|localize_translatable_string }} {{ 'View the report' | trans }} {{ 'Update the report' | trans }} From 17b8c69bca10213b3f9ffa411644cd7617a7b785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 27 Jun 2015 02:03:09 +0200 Subject: [PATCH 116/210] fix tests + test about report ACL --- Tests/Controller/ReportControllerNextTest.php | 178 ++++++++++++++++ Tests/Controller/ReportControllerTest.php | 198 ++++++++++++------ Tests/Fixtures/App/app/AppKernel.php | 1 + Tests/Fixtures/App/app/config/config_test.yml | 2 +- composer.json | 5 +- 5 files changed, 318 insertions(+), 66 deletions(-) create mode 100644 Tests/Controller/ReportControllerNextTest.php diff --git a/Tests/Controller/ReportControllerNextTest.php b/Tests/Controller/ReportControllerNextTest.php new file mode 100644 index 000000000..e3c96bf22 --- /dev/null +++ b/Tests/Controller/ReportControllerNextTest.php @@ -0,0 +1,178 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ReportBundle\Tests\Controller; + +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Chill\PersonBundle\Entity\Person; +use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; +use Symfony\Component\BrowserKit\Client; + +/** + * This class is much well writtend than ReportControllerTest class, and will + * replace ReportControllerTest in the future. + * + * @author Julien Fastré + */ +class ReportControllerNextTest extends WebTestCase +{ + /** + * + * @var Person + */ + protected $person; + + /** + * + * @var CustomFieldsGroup + */ + protected $group; + + + public function setUp() + { + static::bootKernel(); + // get person from fixture + $em = static::$kernel->getContainer() + ->get('doctrine.orm.entity_manager'); + + $this->person = $em + ->getRepository('ChillPersonBundle:Person') + ->findOneBy(array( + 'lastName' => 'Charline', + 'firstName' => 'Depardieu' + ) + ); + + if ($this->person === NULL) { + throw new \RuntimeException("The expected person is not present in the database. " + . "Did you run `php app/console doctrine:fixture:load` before launching tests ? " + . "(expecting person is 'Charline Depardieu'"); + } + + // get custom fields group from fixture + $customFieldsGroups = static::$kernel->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->findBy(array('entity' => 'Chill\ReportBundle\Entity\Report')) + ; + //filter customFieldsGroup to get only "situation de logement" + $filteredCustomFieldsGroupHouse = array_filter($customFieldsGroups, + function(CustomFieldsGroup $group) { + return in_array("Situation de logement", $group->getName()); + }); + $this->group = $filteredCustomFieldsGroupHouse[0]; + } + + public function testValidCreate() + { + $client = $this->getAuthenticatedClient(); + $form = $this->getReportForm($this->person, $this->group, $client); + + $form->get('chill_reportbundle_report[date]')->setValue( + (new \DateTime())->format('d-m-Y')); + + $client->submit($form); + + $this->assertTrue($client->getResponse()->isRedirect(), + "The next page is a redirection to the new report's view page"); + + } + + public function testUngrantedUserIsDeniedAccessOnListReports() + { + $client = $this->getAuthenticatedClient('center b_social'); + $client->request('GET', sprintf('/fr/person/%d/report/list', + $this->person->getId())); + + $this->assertEquals(403, $client->getResponse()->getStatusCode(), + 'assert that user for center b has a 403 status code when listing' + . 'reports on person from center a'); + } + + public function testUngrantedUserIsDeniedAccessOnReport() + { + $client = $this->getAuthenticatedClient('center b_social'); + $reports = static::$kernel->getContainer()->get('doctrine.orm.entity_manager') + ->getRepository('ChillReportBundle:Report') + ->findBy(array('person' => $this->person)); + $report = $reports[0]; + + $client->request('GET', sprintf('/fr/person/%d/report/%d/view', + $this->person->getId(), $report->getId())); + + $this->assertEquals(403, $client->getResponse()->getStatusCode(), + 'assert that user for center b has a 403 status code when ' + . 'trying to watch a report from person from center a'); + } + + public function testUngrantedUserIsDeniedReportNew() + { + $client = $this->getAuthenticatedClient('center b_social'); + + $client->request('GET', sprintf('fr/person/%d/report/cfgroup/%d/new', + $this->person->getId(), $this->group->getId())); + + $this->assertEquals(403, $client->getResponse()->getStatusCode(), + 'assert that user is denied on trying to show a form "new" for' + . ' a person on another center'); + } + + public function testUngrantedUserIsDeniedReportCreate() + { + $clientCenterA = $this->getAuthenticatedClient('center a_social'); + + $form = $this->getReportForm($this->person, $this->group, $clientCenterA); + + $clientCenterB = $this->getAuthenticatedClient('center b_social'); + $clientCenterB->submit($form); + + $this->assertEquals(403, $clientCenterB->getResponse()->getStatusCode(), + 'assert that user is denied on trying to show a form "new" for' + . ' a person on another center'); + } + + protected function getAuthenticatedClient($username = 'center a_social') + { + return static::createClient(array(), array( + 'PHP_AUTH_USER' => $username, + 'PHP_AUTH_PW' => 'password', + )); + } + + /** + * + * @param Person $person + * @param CustomFieldsGroup $group + * @param Client $client + * @return \Symfony\Component\DomCrawler\Form + */ + protected function getReportForm(Person $person, CustomFieldsGroup $group, Client $client) + { + $url = sprintf('fr/person/%d/report/cfgroup/%d/new', $person->getId(), + $group->getId()); + $crawler = $client->request('GET', $url); + + return $crawler->selectButton('Ajouter le rapport') + ->form(); + } + + + +} diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index 177640735..7fb485a7d 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -26,6 +26,8 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\DomCrawler\Form; use Symfony\Component\DomCrawler\Link; use Symfony\Component\DomCrawler\Crawler; +use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; +use Chill\PersonBundle\Entity\Person; /** * Test the life cycles of controllers, according to @@ -52,6 +54,12 @@ class ReportControllerTest extends WebTestCase private static $user; + /** + * + * @var CustomFieldsGroup + */ + private static $group; + /** * * @var \Doctrine\ORM\EntityManagerInterface @@ -66,16 +74,32 @@ class ReportControllerTest extends WebTestCase ->get('doctrine.orm.entity_manager'); //get a random person - $persons = static::$kernel->getContainer() + static::$person = static::$kernel->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('ChillPersonBundle:Person') - ->findAll(); - static::$person = $persons[array_rand($persons)]; + ->findOneBy(array( + 'lastName' => 'Charline', + 'firstName' => 'Depardieu' + ) + ); - static::$client = static::createClient(array(), array( - 'PHP_AUTH_USER' => 'center a_social', - 'PHP_AUTH_PW' => 'password', - )); + if (static::$person === NULL) { + throw new \RuntimeException("The expected person is not present in the database. " + . "Did you run `php app/console doctrine:fixture:load` before launching tests ? " + . "(expecting person is 'Charline Depardieu'"); + } + + $customFieldsGroups = static::$kernel->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->findBy(array('entity' => 'Chill\ReportBundle\Entity\Report')) + ; + //filter customFieldsGroup to get only "situation de logement" + $filteredCustomFieldsGroupHouse = array_filter($customFieldsGroups, + function(CustomFieldsGroup $group) { + return in_array("Situation de logement", $group->getName()); + }); + static::$group = $filteredCustomFieldsGroupHouse[0]; static::$user = static::$kernel->getContainer() ->get('doctrine.orm.entity_manager') @@ -83,6 +107,27 @@ class ReportControllerTest extends WebTestCase ->findOneBy(array('username' => "center a_social")); } + public function setUp() + { + static::$client = static::createClient(array(), array( + 'PHP_AUTH_USER' => 'center a_social', + 'PHP_AUTH_PW' => 'password', + )); + } + + /** + * + * @param type $username + * @return Client + */ + public function getAuthenticatedClient($username = 'center a_social') + { + return static::createClient(array(), array( + 'PHP_AUTH_USER' => $username, + 'PHP_AUTH_PW' => 'password', + )); + } + /** * Set up the browser to be at a random person general page (/fr/person/%d/general), * check if there is a menu link for adding a new report and return this link (as producer) @@ -94,10 +139,11 @@ class ReportControllerTest extends WebTestCase */ public function testMenu() { - $crawlerPersonPage = static::$client->request('GET', sprintf('/fr/person/%d/general', + $client = $this->getAuthenticatedClient(); + $crawlerPersonPage = $client->request('GET', sprintf('/fr/person/%d/general', static::$person->getId())); - if (! static::$client->getResponse()->isSuccessful()) { + if (! $client->getResponse()->isSuccessful()) { var_dump($crawlerPersonPage->html()); throw new \RuntimeException('the request at person page failed'); } @@ -121,7 +167,8 @@ class ReportControllerTest extends WebTestCase public function testChooseReportModelPage(Link $link) { // When I click on "add a report" link in menu - $crawlerAddAReportPage = static::$client->click($link); + $client = $this->getAuthenticatedClient(); + $crawlerAddAReportPage = $client->click($link); $form = $crawlerAddAReportPage->selectButton("Créer un nouveau rapport")->form(); @@ -137,10 +184,10 @@ class ReportControllerTest extends WebTestCase $form->get(self::REPORT_NAME_FIELD)->setValue( $possibleOptionsValue[array_rand($possibleOptionsValue)]); - static::$client->submit($form); + $client->submit($form); - $this->assertTrue(static::$client->getResponse()->isRedirect()); - return static::$client->followRedirect(); + $this->assertTrue($client->getResponse()->isRedirect()); + return $client->followRedirect(); } /** @@ -164,6 +211,24 @@ class ReportControllerTest extends WebTestCase return $addForm; } + /** + * get a form for report new + * + * @param \Chill\ReportBundle\Tests\Controller\Person $person + * @param CustomFieldsGroup $group + * @param \Symfony\Component\BrowserKit\Client $client + * @return Form + */ + protected function getReportForm(Person $person, CustomFieldsGroup $group, + \Symfony\Component\BrowserKit\Client $client) + { + $url = sprintf('fr/person/%d/report/cfgroup/%d/new', $person->getId(), + $group->getId()); + $crawler = $client->request('GET', $url); + + return $crawler->selectButton('Ajouter le rapport') + ->form(); + } /** * Test the expected field are present @@ -207,10 +272,6 @@ class ReportControllerTest extends WebTestCase { $form->get('chill_reportbundle_report[date]')->setValue( (new \DateTime())->format('d-m-Y')); - //get the first option values - $form->get('chill_reportbundle_report[user]')->setValue( - $form->get('chill_reportbundle_report[user]') - ->availableOptionValues()[0]); return $form; } @@ -218,23 +279,19 @@ class ReportControllerTest extends WebTestCase /** * Test that setting a Null date redirect to an error page * - * @param Form $form - * @depends testNewReportPage */ - public function testNullDate(Form $form) + public function testNullDate() { - $this->markTestSkipped("This test raise an error since symfony 2.7. " - . "The user is not correctly reloaded from database."); + $client = $this->getAuthenticatedClient(); + $form = $this->getReportForm(static::$person, static::$group, + $client); + //var_dump($form); $filledForm = $this->fillCorrectForm($form); $filledForm->get('chill_reportbundle_report[date]')->setValue(''); - - $client = static::createClient(array(), array( - 'PHP_AUTH_USER' => 'center a_social', - 'PHP_AUTH_PW' => 'password', - )); - $crawler = $client->submit($filledForm); - var_dump($crawler->text()); - $this->assertFalse(static::$client->getResponse()->isRedirect()); + //$this->markTestSkipped(); + $crawler = $this->getAuthenticatedClient('center a_administrative')->submit($filledForm); + + $this->assertFalse($client->getResponse()->isRedirect()); $this->assertGreaterThan(0, $crawler->filter('.error')->count()); } @@ -246,14 +303,15 @@ class ReportControllerTest extends WebTestCase */ public function testInvalidDate(Form $form) { + $client = $this->getAuthenticatedClient(); $this->markTestSkipped("This test raise an error since symfony 2.7. " . "The user is not correctly reloaded from database."); $filledForm = $this->fillCorrectForm($form); $filledForm->get('chill_reportbundle_report[date]')->setValue('invalid date value'); - $crawler = static::$client->submit($filledForm); + $crawler = $client->submit($filledForm); - $this->assertFalse(static::$client->getResponse()->isRedirect()); + $this->assertFalse($client->getResponse()->isRedirect()); $this->assertGreaterThan(0, $crawler->filter('.error')->count()); } @@ -265,41 +323,44 @@ class ReportControllerTest extends WebTestCase */ public function testInvalidUser(Form $form) { + $client = $this->getAuthenticatedClient(); $filledForm = $this->fillCorrectForm($form); $select = $filledForm->get('chill_reportbundle_report[user]') ->disableValidation() ->setValue(-1); - $crawler = static::$client->submit($filledForm); + $crawler = $client->submit($filledForm); - $this->assertFalse(static::$client->getResponse()->isRedirect()); + $this->assertFalse($client->getResponse()->isRedirect()); $this->assertGreaterThan(0, $crawler->filter('.error')->count()); } /** * Test the creation of a report * - * @depends testNewReportPage - * @param Form $form + * depends testNewReportPage + * param Form $form */ - public function testValidCreate(Form $addForm) + public function testValidCreate() { - $this->markTestSkipped("This test raise an error since symfony 2.7. " - . "The user is not correctly reloaded from database."); + $client = $this->getAuthenticatedClient(); + //$this->markTestSkipped("This test raise an error since symfony 2.7. " + // . "The user is not correctly reloaded from database."); + $addForm = $this->getReportForm(self::$person, self::$group, $client); $filledForm = $this->fillCorrectForm($addForm); - $c = static::$client->submit($filledForm); - var_dump($c->text()); - $this->assertTrue(static::$client->getResponse()->isRedirect(), + $c = $client->submit($filledForm); + + $this->assertTrue($client->getResponse()->isRedirect(), "The next page is a redirection to the new report's view page"); - static::$client->followRedirect(); + $client->followRedirect(); $this->assertRegExp("|/fr/person/".static::$person->getId()."/report/[0-9]*/view$|", - static::$client->getHistory()->current()->getUri(), + $client->getHistory()->current()->getUri(), "The next page is a redirection to the new report's view page"); $matches = array(); preg_match('|/report/([0-9]*)/view$|', - static::$client->getHistory()->current()->getUri(), $matches); + $client->getHistory()->current()->getUri(), $matches); return $matches[1]; } @@ -311,10 +372,11 @@ class ReportControllerTest extends WebTestCase */ public function testList($reportId) { - $crawler = static::$client->request('GET', sprintf('/fr/person/%s/report/list', + $client = $this->getAuthenticatedClient(); + $crawler = $client->request('GET', sprintf('/fr/person/%s/report/list', static::$person->getId())); - $this->assertTrue(static::$client->getResponse()->isSuccessful()); + $this->assertTrue($client->getResponse()->isSuccessful()); $linkSee = $crawler->selectLink('Voir le rapport')->links(); $this->assertGreaterThan(0, count($linkSee)); @@ -336,10 +398,11 @@ class ReportControllerTest extends WebTestCase */ public function testView($reportId) { - static::$client->request('GET', + $client = $this->getAuthenticatedClient(); + $client->request('GET', sprintf('/fr/person/%s/report/%s/view', static::$person->getId(), $reportId)); - $this->assertTrue(static::$client->getResponse()->isSuccessful(), + $this->assertTrue($client->getResponse()->isSuccessful(), 'the page is shown'); } @@ -351,10 +414,11 @@ class ReportControllerTest extends WebTestCase */ public function testUpdate($reportId) { - $crawler = static::$client->request('GET', + $client = $this->getAuthenticatedClient(); + $crawler = $client->request('GET', sprintf('/fr/person/%s/report/%s/edit', static::$person->getId(), $reportId)); - $this->assertTrue(static::$client->getResponse()->isSuccessful()); + $this->assertTrue($client->getResponse()->isSuccessful()); $form = $crawler ->selectButton('Enregistrer le rapport') @@ -363,9 +427,9 @@ class ReportControllerTest extends WebTestCase $form->get('chill_reportbundle_report[date]')->setValue( (new \DateTime('yesterday'))->format('d-m-Y')); - static::$client->submit($form); + $client->submit($form); - $this->assertTrue(static::$client->getResponse()->isRedirect( + $this->assertTrue($client->getResponse()->isRedirect( sprintf('/fr/person/%s/report/%s/view', static::$person->getId(), $reportId))); @@ -385,9 +449,10 @@ class ReportControllerTest extends WebTestCase */ public function testLinkToTheExportReport() { - $crawlerReportExportPage = static::$client->request('GET', '/fr/export'); + $client = $this->getAuthenticatedClient(); + $crawlerReportExportPage = $client->request('GET', '/fr/export'); - if (! static::$client->getResponse()->isSuccessful()) { + if (! $client->getResponse()->isSuccessful()) { var_dump($crawlerReportExportPage->html()); throw new \RuntimeException('The get request at export page failed'); } @@ -413,7 +478,8 @@ class ReportControllerTest extends WebTestCase */ public function testFormForExportAction(Link $link) { - $crawlerExportReportPage = static::$client->click($link); + $client = $this->getAuthenticatedClient(); + $crawlerExportReportPage = $client->click($link); $form = $crawlerExportReportPage->selectButton("Export this kind of reports")->form(); @@ -432,11 +498,11 @@ class ReportControllerTest extends WebTestCase $form->get(self::REPORT_NAME_FIELD)->setValue($cfGroupId); - static::$client->submit($form); + $client->submit($form); - $this->assertTrue(static::$client->getResponse()->isRedirect()); + $this->assertTrue($client->getResponse()->isRedirect()); - static::$client->followRedirect(); + $client->followRedirect(); return $cfGroupId; } @@ -454,7 +520,11 @@ class ReportControllerTest extends WebTestCase */ public function testCSVExportAction($cfGroupId) { - $response = static::$client->getResponse(); + $client = $this->getAuthenticatedClient(); + + $client->request('GET', 'fr/export/report/cfgroup/'. + static::$group->getId()); + $response = $client->getResponse(); $this->assertTrue( strpos($response->headers->get('Content-Type'),'text/csv') !== false, @@ -480,10 +550,12 @@ class ReportControllerTest extends WebTestCase } $cfGroup = static::$em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cfGroupId); - $reports = static::$em->getRepository('ChillReportBundle:Report')->findByCFGroup($cfGroup); + $reports = static::$em->getRepository('ChillReportBundle:Report') + ->findByCFGroup($cfGroup); - $this->assertTrue( - $numberOfRows == sizeof($reports), + $this->markTestSkipped(); + $this->assertEquals( + $numberOfRows, sizeof($reports), 'The csv file has a number of row equivalent than the number of reports in the db' ); } diff --git a/Tests/Fixtures/App/app/AppKernel.php b/Tests/Fixtures/App/app/AppKernel.php index c77c6e886..4222efe69 100644 --- a/Tests/Fixtures/App/app/AppKernel.php +++ b/Tests/Fixtures/App/app/AppKernel.php @@ -10,6 +10,7 @@ class AppKernel extends Kernel return array( new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Chill\ReportBundle\ChillReportBundle(), + new Symfony\Bundle\MonologBundle\MonologBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Chill\CustomFieldsBundle\ChillCustomFieldsBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), diff --git a/Tests/Fixtures/App/app/config/config_test.yml b/Tests/Fixtures/App/app/config/config_test.yml index 81e0f80f4..812b1a09c 100644 --- a/Tests/Fixtures/App/app/config/config_test.yml +++ b/Tests/Fixtures/App/app/config/config_test.yml @@ -4,4 +4,4 @@ imports: framework: test: ~ session: - storage_id: session.storage.filesystem \ No newline at end of file + storage_id: session.storage.filesystem diff --git a/composer.json b/composer.json index df02bd3e5..94ddfa0ce 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,6 @@ "require": { "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", - "symfony/monolog-bundle": "~2.4", "symfony/framework-bundle": "~2.7", "symfony/yaml": "~2.7", "symfony/symfony": "~2.7", @@ -35,7 +34,9 @@ }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "~2.2", - "fzaninotto/faker": "~1" + "fzaninotto/faker": "~1", + "monolog/monolog": "^1.14", + "symfony/monolog-bundle": "^2.7" }, "scripts": { "post-install-cmd": [ From 4947db1c7f75cb22a774c120ecf46eb070edbb27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 28 Jun 2015 11:24:48 +0200 Subject: [PATCH 117/210] fix username in test timeline --- Tests/Timeline/TimelineProviderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Timeline/TimelineProviderTest.php b/Tests/Timeline/TimelineProviderTest.php index 904136770..afd3afc17 100644 --- a/Tests/Timeline/TimelineProviderTest.php +++ b/Tests/Timeline/TimelineProviderTest.php @@ -74,7 +74,7 @@ class TimelineProviderTest extends WebTestCase $this->report = (new Report) ->setUser(static::$em->getRepository('ChillMainBundle:User') - ->findOneByUsername('chill b_social')) + ->findOneByUsername('center b_social')) ->setDate(new \DateTime('2015-05-02')) ->setPerson($this->person) ->setCFGroup($this->getHousingCustomFieldsGroup()) From 4c04416fd5ce8fe0841822302a96d8c27262797f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 28 Jun 2015 11:37:16 +0200 Subject: [PATCH 118/210] =?UTF-8?q?add=20Scope=20to=20report's=20fixture?= =?UTF-8?q?=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DataFixtures/ORM/LoadReports.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/DataFixtures/ORM/LoadReports.php b/DataFixtures/ORM/LoadReports.php index ed284051b..6b70cfacd 100644 --- a/DataFixtures/ORM/LoadReports.php +++ b/DataFixtures/ORM/LoadReports.php @@ -28,6 +28,7 @@ use Chill\ReportBundle\Entity\Report; use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Faker\Factory as FakerFactory; use Chill\CustomFieldsBundle\Entity\CustomField; +use Chill\MainBundle\DataFixtures\ORM\LoadScopes; /** * Load reports into DB @@ -78,7 +79,9 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co ->setCFGroup(rand(0,10) > 5 ? $this->getReference('cf_group_report_logement') : $this->getReference('cf_group_report_education') - ); + ) + ->setScope($this->getScopeRandom()) + ; $this->fillReport($report); $manager->persist($report); } @@ -95,12 +98,23 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co ->setPerson($charline) ->setCFGroup($this->getReference('cf_group_report_logement')) ->setDate(new \DateTime('2015-01-05')) + ->setScope($this->getReference('scope_social')) ; $this->fillReport($report); $manager->persist($report); } + /** + * + * @return \Chill\MainBundle\Entity\Scope + */ + private function getScopeRandom() + { + $ref = LoadScopes::$references[array_rand(LoadScopes::$references)]; + return $this->getReference($ref); + } + private function getPeopleRandom($percentage) { $people = $this->container->get('doctrine.orm.entity_manager') From acb3e8bc3da6dc93024c01263bce4b8978babce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 29 Jun 2015 23:38:21 +0200 Subject: [PATCH 119/210] add acl on timeline report --- DataFixtures/ORM/LoadReportACL.php | 10 ++- Resources/config/services.yml | 2 + Tests/Timeline/TimelineProviderTest.php | 40 ++++++++-- Timeline/TimelineReportProvider.php | 97 ++++++++++++++++++++++--- 4 files changed, 131 insertions(+), 18 deletions(-) diff --git a/DataFixtures/ORM/LoadReportACL.php b/DataFixtures/ORM/LoadReportACL.php index 0cec37b42..429fac99c 100644 --- a/DataFixtures/ORM/LoadReportACL.php +++ b/DataFixtures/ORM/LoadReportACL.php @@ -44,19 +44,25 @@ class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { $permissionsGroup = $this->getReference($permissionsGroupRef); + printf("processing permission group %s \n", $permissionsGroup->getName()); foreach (LoadScopes::$references as $scopeRef){ $scope = $this->getReference($scopeRef); + printf("processing scope %s \n", $scope->getName()['en']); //create permission group switch ($permissionsGroup->getName()) { case 'social': if ($scope->getName()['en'] === 'administrative') { - continue; // we do not want any power on administrative + printf("denying power on administrative \n"); + break 2; // we do not want any power on administrative } + break; case 'administrative': case 'direction': if (in_array($scope->getName()['en'], array('administrative', 'social'))) { - continue; // we do not want any power on social or administrative + printf("denying power on %s\n", $scope->getName()['en']); + break 2; // we do not want any power on social or administrative } + break; } printf("Adding CHILL_REPORT_UPDATE & CHILL_REPORT_CREATE to %s " diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 35fbf3b27..82310bc37 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -17,6 +17,8 @@ services: class: Chill\ReportBundle\Timeline\TimelineReportProvider arguments: - '@doctrine.orm.entity_manager' + - '@chill.main.security.authorization.helper' + - '@security.token_storage' tags: - { name: chill.timeline, context: 'person' } diff --git a/Tests/Timeline/TimelineProviderTest.php b/Tests/Timeline/TimelineProviderTest.php index afd3afc17..080a8f288 100644 --- a/Tests/Timeline/TimelineProviderTest.php +++ b/Tests/Timeline/TimelineProviderTest.php @@ -24,6 +24,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Chill\PersonBundle\Entity\Person; use Chill\ReportBundle\Entity\Report; use Chill\MainBundle\Tests\TestHelper as MainTestHelper; +use Chill\MainBundle\Entity\Scope; /** * Test a report is shown into timeline @@ -65,23 +66,32 @@ class TimelineProviderTest extends WebTestCase $center = static::$em->getRepository('ChillMainBundle:Center') ->findOneBy(array('name' => 'Center A')); - $this->person = (new Person(new \DateTime('2015-05-01'))) + $person = (new Person(new \DateTime('2015-05-01'))) ->setGenre(Person::GENRE_WOMAN) ->setFirstName('Nelson') ->setLastName('Mandela') ->setCenter($center); - static::$em->persist($this->person); + static::$em->persist($person); + $this->person = $person; - $this->report = (new Report) + $scopesSocial = array_filter(static::$em + ->getRepository('ChillMainBundle:Scope') + ->findAll(), + function(Scope $scope) { return $scope->getName()['en'] === 'social'; }) + ; + + $report = (new Report) ->setUser(static::$em->getRepository('ChillMainBundle:User') - ->findOneByUsername('center b_social')) + ->findOneByUsername('center a_social')) ->setDate(new \DateTime('2015-05-02')) ->setPerson($this->person) ->setCFGroup($this->getHousingCustomFieldsGroup()) ->setCFData(['has_logement' => 'own_house', - 'house-desc' => 'blah blah']); + 'house-desc' => 'blah blah']) + ->setScope(end($scopesSocial)); - static::$em->persist($this->report); + static::$em->persist($report); + $this->report = $report; @@ -131,6 +141,20 @@ class TimelineProviderTest extends WebTestCase 'the page contains the mention "Propriétaire"'); } + public function testReportIsNotVisibleToUngrantedUsers() + { + $client = static::createClient(array(), + MainTestHelper::getAuthenticatedClientOptions('center a_administrative') + ); + + $crawler = $client->request('GET', '/fr/person/'.$this->person->getId() + .'/timeline'); + + $this->assertEquals(0, $crawler->filter('.report .summary') + ->count(), + 'the page does not contains a .report .summary element'); + } + /** * get a random custom fields group * @@ -155,7 +179,9 @@ class TimelineProviderTest extends WebTestCase public function tearDown() { - //static::$em->remove($this->person); + //static::$em->refresh($this->person); + //static::$em->refresh($this->report); + // static::$em->remove($this->person); //static::$em->remove($this->report); } } diff --git a/Timeline/TimelineReportProvider.php b/Timeline/TimelineReportProvider.php index c9138c9d4..a4d189212 100644 --- a/Timeline/TimelineReportProvider.php +++ b/Timeline/TimelineReportProvider.php @@ -22,6 +22,12 @@ namespace Chill\ReportBundle\Timeline; use Chill\MainBundle\Timeline\TimelineProviderInterface; use Doctrine\ORM\EntityManager; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; +use Symfony\Component\Security\Core\Role\Role; +use Doctrine\ORM\Mapping\ClassMetadata; +use Chill\PersonBundle\Entity\Person; +use Chill\MainBundle\Entity\Scope; /** * Provide report for inclusion in timeline @@ -38,9 +44,30 @@ class TimelineReportProvider implements TimelineProviderInterface */ protected $em; - public function __construct(EntityManager $em) + /** + * + * @var AuthorizationHelper + */ + protected $helper; + + /** + * + * @var \Chill\MainBundle\Entity\User + */ + protected $user; + + public function __construct(EntityManager $em, AuthorizationHelper $helper, + TokenStorage $storage) { $this->em = $em; + $this->helper = $helper; + + if (!$storage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User) + { + throw new \RuntimeException('A user should be authenticated !'); + } + + $this->user = $storage->getToken()->getUser(); } /** @@ -51,19 +78,71 @@ class TimelineReportProvider implements TimelineProviderInterface { $this->checkContext($context); - $metadata = $this->em->getClassMetadata('ChillReportBundle:Report'); + $metadataReport = $this->em->getClassMetadata('ChillReportBundle:Report'); + $metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person'); return array( - 'id' => $metadata->getColumnName('id'), + 'id' => $metadataReport->getTableName() + .'.'.$metadataReport->getColumnName('id'), 'type' => 'report', - 'date' => $metadata->getColumnName('date'), - 'FROM' => $metadata->getTableName(), - 'WHERE' => sprintf('%s = %d', - $metadata - ->getAssociationMapping('person')['joinColumns'][0]['name'], - $args['person']->getId()) + 'date' => $metadataReport->getTableName() + .'.'.$metadataReport->getColumnName('date'), + 'FROM' => $this->getFromClause($metadataReport, $metadataPerson), + 'WHERE' => $this->getWhereClause($metadataReport, $metadataPerson, + $args['person']) ); } + + private function getWhereClause(ClassMetadata $metadataReport, + ClassMetadata $metadataPerson, Person $person) + { + $role = new Role('CHILL_REPORT_SEE'); + $reachableCenters = $this->helper->getReachableCenters($this->user, + $role); + $associationMapping = $metadataReport->getAssociationMapping('person'); + + // we start with reports having the person_id linked to person + // (currently only context "person" is supported) + $whereClause = sprintf('%s = %d', + $associationMapping['joinColumns'][0]['name'], + $person->getId()); + + // we add acl (reachable center and scopes) + $centerAndScopeLines = array(); + foreach ($reachableCenters as $center) { + $reachablesScopesId = array_map( + function(Scope $scope) { return $scope->getId(); }, + $this->helper->getReachableScopes($this->user, $role, + $person->getCenter()) + ); + + $centerAndScopeLines[] = sprintf('(%s = %d AND %s IN (%s))', + $metadataPerson->getTableName().'.'. + $metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'], + $center->getId(), + $metadataReport->getTableName().'.'. + $metadataReport->getAssociationMapping('scope')['joinColumns'][0]['name'], + implode(',', $reachablesScopesId)); + + } + $whereClause .= ' AND ('.implode(' OR ', $centerAndScopeLines).')'; + + return $whereClause; + } + + private function getFromClause(ClassMetadata $metadataReport, + ClassMetadata $metadataPerson) + { + $associationMapping = $metadataReport->getAssociationMapping('person'); + + return $metadataReport->getTableName().' JOIN ' + .$metadataPerson->getTableName().' ON ' + .$metadataPerson->getTableName().'.'. + $associationMapping['joinColumns'][0]['referencedColumnName'] + .' = ' + .$associationMapping['joinColumns'][0]['name'] + ; + } /** * From f14255c0fc1182f1d15c26fc883904dcdae622eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 29 Jun 2015 23:42:14 +0200 Subject: [PATCH 120/210] add scope to search results --- Resources/views/Search/results.html.twig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Resources/views/Search/results.html.twig b/Resources/views/Search/results.html.twig index acb887a46..94f0cd0cf 100644 --- a/Resources/views/Search/results.html.twig +++ b/Resources/views/Search/results.html.twig @@ -25,6 +25,7 @@ {{ 'Person'|trans }} {{ 'Date'|trans }} {{ 'Report type'|trans }} + {{ 'Scope'|trans }}     @@ -35,7 +36,7 @@ {{ report.person }} {% if report.date %}{{ report.date|localizeddate('long', 'none') }}{% endif %} {{ report.cFGroup.getName|localize_translatable_string }} - + {{ report.scope.name|localize_translatable_string }} {{ 'View the report' | trans }} {{ 'Update the report' | trans }} From a16a097550f72139ddb060f924441010dd2f1935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 30 Jun 2015 00:19:10 +0200 Subject: [PATCH 121/210] add acl on report search --- Resources/config/services.yml | 2 ++ Search/ReportSearch.php | 57 ++++++++++++++++++++++++++++++- Tests/Search/ReportSearchTest.php | 27 +++++++++++++-- 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 82310bc37..4d8b4b625 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -8,6 +8,8 @@ services: class: Chill\ReportBundle\Search\ReportSearch arguments: - '@doctrine.orm.entity_manager' + - '@chill.main.security.authorization.helper' + - '@security.token_storage' calls: - [setContainer, ["@service_container"]] tags: diff --git a/Search/ReportSearch.php b/Search/ReportSearch.php index ef5b53965..e5a80716a 100644 --- a/Search/ReportSearch.php +++ b/Search/ReportSearch.php @@ -24,6 +24,11 @@ use Chill\MainBundle\Search\AbstractSearch; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Chill\MainBundle\Search\ParsingException; +use Doctrine\ORM\QueryBuilder; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\Role\Role; +use Chill\MainBundle\Entity\Scope; /** * Search amongst reports @@ -39,9 +44,28 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface */ private $em; - public function __construct(EntityManagerInterface $em) + /** + * + * @var AuthorizationHelper + */ + private $helper; + + /** + * + * @var \Chill\MainBundle\Entity\User + */ + private $user; + + public function __construct(EntityManagerInterface $em, + AuthorizationHelper $helper, TokenStorageInterface $tokenStorage) { $this->em = $em; + $this->helper = $helper; + + if(! $tokenStorage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User) { + throw new \RuntimeException('an user must be associated with token'); + } + $this->user = $tokenStorage->getToken()->getUser(); } public function getOrder() @@ -120,8 +144,39 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface ; } + $query->andWhere($this->addACL($query)); + return $query; } + + private function addACL(QueryBuilder $qb) + { + //adding join + $qb->join('r.person', 'p'); + + $role = new Role('CHILL_REPORT_SEE'); + $reachableCenters = $this->helper->getReachableCenters($this->user, $role); + + $whereElement = $qb->expr()->orX(); + $i = 0; + foreach ($reachableCenters as $center) { + $reachableScopesId = array_map( + function (Scope $scope) { return $scope->getId(); }, + $this->helper->getReachableScopes($this->user, $role, $center) + ); + $whereElement->add( + $qb->expr()->andX( + $qb->expr()->eq('p.center', ':center_'.$i), + $qb->expr()->in('r.scope', ':reachable_scopes_'.$i) + ) + ) + ; + $qb->setParameter('center_'.$i, $center); + $qb->setParameter('reachable_scopes_'.$i, $reachableScopesId); + } + + return $whereElement; + } public function supports($domain) { diff --git a/Tests/Search/ReportSearchTest.php b/Tests/Search/ReportSearchTest.php index 60008e0cd..b650c7cea 100644 --- a/Tests/Search/ReportSearchTest.php +++ b/Tests/Search/ReportSearchTest.php @@ -90,17 +90,38 @@ class ReportSearchTest extends WebTestCase $this->assertGreaterThan(0, $crawler->filter('.error')->count()); } - + /** + * Test that the user do not see unauthorized results + * + * We test for that that : + * - we do not see any unauthorized scope mention + */ + public function testUsersDoNotSeeUnauthorizedResults() + { + $clientSocial = $this->getAuthenticatedClient(); + $clientAdministrative = $this->getAuthenticatedClient('center a_administrative'); + + $params = array('q' => '@report date:2015-01-05'); + + $crawlerSocial = $clientSocial->request('GET', '/fr/search', $params); + $crawlerAdministrative = $clientAdministrative->request('GET', '/fr/search', $params); + + + $this->assertNotContains('social', $crawlerAdministrative->filter('.content') + ->text()); + $this->assertNotContains('administrative', $crawlerAdministrative->filter('.content') + ->text()); + } /** * * @return \Symfony\Component\BrowserKit\Client */ - private function getAuthenticatedClient() + private function getAuthenticatedClient($username = 'center a_social') { return static::createClient(array(), array( - 'PHP_AUTH_USER' => 'center a_social', + 'PHP_AUTH_USER' => $username, 'PHP_AUTH_PW' => 'password', )); } From 03f1243cf71c4e9d502bf46d7fd93091bced9112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 30 Jun 2015 14:34:55 +0200 Subject: [PATCH 122/210] set composer.json to master branches --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 94ddfa0ce..197bef509 100644 --- a/composer.json +++ b/composer.json @@ -25,9 +25,9 @@ "doctrine/orm": "~2.4", "doctrine/common": "~2.4", "doctrine/doctrine-bundle": "~1.2", - "chill-project/main": "dev-add_acl@dev", - "chill-project/custom-fields": "dev-add_acl@dev", - "chill-project/person": "dev-add_acl@dev", + "chill-project/main": "dev-master@dev", + "chill-project/custom-fields": "dev-master@dev", + "chill-project/person": "dev-master@dev", "champs-libres/composer-bundle-migration": "~1.0", "doctrine/doctrine-migrations-bundle": "dev-master@dev", "doctrine/migrations": "~1.0@dev" From ea1d8d04affce7e2abc5e3ecf2891c27e018e80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 30 Jun 2015 15:46:46 +0200 Subject: [PATCH 123/210] add a default behaviour on adding scope column To ensure backward-compatibility, add a default scope during schema modification, if reports are already present in database. --- .../migrations/Version20150622233319.php | 69 ++++++++++++++++++- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/Resources/migrations/Version20150622233319.php b/Resources/migrations/Version20150622233319.php index 3ef33fbef..7d4342a29 100644 --- a/Resources/migrations/Version20150622233319.php +++ b/Resources/migrations/Version20150622233319.php @@ -4,12 +4,33 @@ namespace Application\Migrations; use Doctrine\DBAL\Migrations\AbstractMigration; use Doctrine\DBAL\Schema\Schema; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Chill\MainBundle\Entity\Scope; + /** * Add a scope to report */ -class Version20150622233319 extends AbstractMigration +class Version20150622233319 extends AbstractMigration + implements ContainerAwareInterface { + /** + * + * @var ContainerInterface + */ + private $container; + + public function setContainer(ContainerInterface $container = null) + { + if ($container === NULL) { + throw new \RuntimeException('Container is not provided. This migration ' + . 'need container to set a default center'); + } + + $this->container = $container; + } + /** * @param Schema $schema */ @@ -19,10 +40,52 @@ class Version20150622233319 extends AbstractMigration 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE report ADD scope_id INT DEFAULT NULL'); + + //add a default scope + $scopes = $this->container->get('doctrine.orm.default_entity_manager') + ->getRepository('ChillMainBundle:Scope') + ->findAll(); + + if (count($scopes) > 0) { + $defaultScopeId = $scopes[0]->getId(); + } else { + //check if there are data in report table + $nbReports = $this->container->get('doctrine.orm.default_entity_manager') + ->createQuery('SELECT count(r.id) FROM ChillReportBundle:Report r') + ->getSingleScalarResult(); + + if ($nbReports > 0) { + //create a default scope + $scope = new Scope(); + //create name according to installed languages + $locales = $this->container + ->getParameter('chill_main.available_languages'); + $names = array(); + foreach($locales as $locale) { + $names[$locale] = 'default'; + } + $scope->setName($names); + //persist + $this->container->get('doctrine.orm.default_entity_manager') + ->persist($scope); + $this->container->get('doctrine.orm.default_entity_manager') + ->flush(); + //default scope is the newly-created one + $defaultScopeId = $scope->getId(); + } + } + $this->addSql('ALTER TABLE report DROP scope'); //before this migration, scope was never used $this->addSql('ALTER TABLE report ADD CONSTRAINT FK_report_scope ' . 'FOREIGN KEY (scope_id) ' . 'REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + + if (isset($defaultScopeId)){ + $this->addSql('UPDATE report SET scope_id = :id', array( + 'id' => $defaultScopeId + )); + } + $this->addSql('ALTER TABLE report ALTER COLUMN scope_id SET NOT NULL'); $this->addSql('CREATE INDEX IDX_report_scope ON report (scope_id)'); } @@ -34,8 +97,8 @@ class Version20150622233319 extends AbstractMigration $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); - $this->addSql('ALTER TABLE Report DROP CONSTRAINT FK_C38372B2682B5931'); - $this->addSql('DROP INDEX IDX_C38372B2682B5931'); + $this->addSql('ALTER TABLE Report DROP CONSTRAINT FK_report_scope'); + $this->addSql('DROP INDEX IDX_report_scope'); $this->addSql('ALTER TABLE Report ADD scope VARCHAR(255) DEFAULT NULL'); $this->addSql('ALTER TABLE Report DROP scope_id'); } From 1f58e60c09831c126ee5ce32f4c28b6458844f8f Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 6 Jul 2015 00:31:30 +0200 Subject: [PATCH 124/210] Refactoring LoadReports : removing useless line return --- DataFixtures/ORM/LoadReports.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/DataFixtures/ORM/LoadReports.php b/DataFixtures/ORM/LoadReports.php index 6b70cfacd..30eb419df 100644 --- a/DataFixtures/ORM/LoadReports.php +++ b/DataFixtures/ORM/LoadReports.php @@ -57,8 +57,6 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co public function load(ObjectManager $manager) { - - $this->createExpected($manager); //create random 2 times, to allow multiple report on some people From 02a48c32c12b732b619044ad9bebcd9bcb4888ab Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 26 Aug 2015 13:36:04 +0200 Subject: [PATCH 125/210] Adding colors for table header of Report/list --- Resources/views/Report/list.html.twig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index 56b9e0faf..3641564fa 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -24,9 +24,9 @@ - - - + + + From f301dbdd1706936b44b0473e839d0db6c33ec3af Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 26 Aug 2015 15:04:12 +0200 Subject: [PATCH 126/210] Correction of tests --- Tests/Controller/ReportControllerTest.php | 2 +- Tests/Timeline/TimelineProviderTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index 7fb485a7d..e5373b339 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -148,7 +148,7 @@ class ReportControllerTest extends WebTestCase throw new \RuntimeException('the request at person page failed'); } - $link = $crawlerPersonPage->selectLink("Ajout d'un rapport")->link(); + $link = $crawlerPersonPage->selectLink("AJOUT D'UN RAPPORT")->link(); $this->assertInstanceOf('Symfony\Component\DomCrawler\Link', $link, "There is a \"add a report\" link in menu"); $this->assertContains(sprintf("/fr/person/%d/report/select/type/for/creation", diff --git a/Tests/Timeline/TimelineProviderTest.php b/Tests/Timeline/TimelineProviderTest.php index 080a8f288..5df8e22fd 100644 --- a/Tests/Timeline/TimelineProviderTest.php +++ b/Tests/Timeline/TimelineProviderTest.php @@ -67,7 +67,7 @@ class TimelineProviderTest extends WebTestCase ->findOneBy(array('name' => 'Center A')); $person = (new Person(new \DateTime('2015-05-01'))) - ->setGenre(Person::GENRE_WOMAN) + ->setGender(Person::FEMALE_GENDER) ->setFirstName('Nelson') ->setLastName('Mandela') ->setCenter($center); From 6b3b1768494d7b2f8699596eee0e15ccab06cd69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Sep 2015 21:47:52 +0200 Subject: [PATCH 127/210] Merge add_ui_permission into master MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + set deps to chill-project/main dev-master Squashed commit of the following: commit c120c9347606358daec042b0e1e3da83cc260f12 Author: Julien Fastré Date: Mon Sep 14 00:50:50 2015 +0200 switch to role declaration in code commit 7fba35356ea9266c43a6f104290103071e1c1755 Author: Julien Fastré Date: Mon Aug 31 23:57:59 2015 +0200 declare role in chill.available_roles parameter --- Resources/config/services.yml | 1 + Security/Authorization/ReportVoter.php | 14 +++++++++++++- composer.json | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 4d8b4b625..326990d35 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -30,6 +30,7 @@ services: - "@chill.main.security.authorization.helper" tags: - { name: security.voter } + - { name: chill.role } chill.report.form.report_type: class: Chill\ReportBundle\Form\ReportType diff --git a/Security/Authorization/ReportVoter.php b/Security/Authorization/ReportVoter.php index e363923df..e3218fec7 100644 --- a/Security/Authorization/ReportVoter.php +++ b/Security/Authorization/ReportVoter.php @@ -21,13 +21,14 @@ namespace Chill\ReportBundle\Security\Authorization; use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\MainBundle\Security\ProvideRoleInterface; /** * * * @author Julien Fastré */ -class ReportVoter extends AbstractChillVoter +class ReportVoter extends AbstractChillVoter implements ProvideRoleInterface { const CREATE = 'CHILL_REPORT_CREATE'; const SEE = 'CHILL_REPORT_SEE'; @@ -63,4 +64,15 @@ class ReportVoter extends AbstractChillVoter return $this->helper->userHasAccess($user, $report, $attribute); } + + public function getRoles() + { + return $this->getSupportedAttributes(); + } + + public function getRolesWithoutScope() + { + return array(); + } + } diff --git a/composer.json b/composer.json index 197bef509..38e26d831 100644 --- a/composer.json +++ b/composer.json @@ -25,9 +25,9 @@ "doctrine/orm": "~2.4", "doctrine/common": "~2.4", "doctrine/doctrine-bundle": "~1.2", - "chill-project/main": "dev-master@dev", + "chill-project/main": "dev-master", "chill-project/custom-fields": "dev-master@dev", - "chill-project/person": "dev-master@dev", + "chill-project/person": "dev-master", "champs-libres/composer-bundle-migration": "~1.0", "doctrine/doctrine-migrations-bundle": "dev-master@dev", "doctrine/migrations": "~1.0@dev" From 6acba49f38938f80458258f5fa46ee69df95e90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Sep 2015 21:50:10 +0200 Subject: [PATCH 128/210] translation in messages refs #573 0h05 --- Resources/translations/messages.fr.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 97569e262..9874c8b19 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -36,3 +36,8 @@ User: Utilisateur #timeline '%user% has filled a %report_label% report on %date%': %user% a ajouté un rapport '%report_label%' le %date% + +#roles +CHILL_REPORT_UPDATE: Modifier les rapports +CHILL_REPORT_SEE: Voir les rapports +CHILL_REPORT_CREATE: Créer des rapports \ No newline at end of file From 426849f169825ed39cca4c510f455c71ea5f65a0 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 30 Sep 2015 14:56:06 +0200 Subject: [PATCH 129/210] Only display custom fields that are active --- Resources/views/Report/export.csv.twig | 4 ++-- Resources/views/Report/view.html.twig | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Resources/views/Report/export.csv.twig b/Resources/views/Report/export.csv.twig index 90217f1db..e2dcb15c6 100644 --- a/Resources/views/Report/export.csv.twig +++ b/Resources/views/Report/export.csv.twig @@ -4,7 +4,7 @@ #}"{{ 'Date'|trans }}",{# #}"{{ 'User'|trans }}",{# #}"{{ 'Report type'|trans }}",{# -#}{% for customField in cf_group.customFields %}{# +#}{% for customField in cf_group.activeCustomFields %}{# #}"{{ chill_custom_field_label(customField) }}"{% if not loop.last %},{% endif %}{# #}{% endfor %}{# @@ -16,7 +16,7 @@ #}"{{ report.date|localizeddate('short', 'none') }}",{# #}"{{ report.user|csv_cell }}",{# #}"{{ report.cFGroup.getName(app.request.locale)|csv_cell }}",{# - #}{% for customField in report.cFGroup.customFields %}{# + #}{% for customField in report.cFGroup.activeCustomFields %}{# #}{% if customField.type == 'title' %}{# #}""{# #}{% else %}{# diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 0d964007a..b344219c9 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -39,14 +39,7 @@
{{ 'Report type'|trans }}
{{ entity.cFGroup.getName(app.request.locale) }}
- {% for customField in entity.cFGroup.customFields %} - {% if customField.type == 'title' %} - {{ chill_custom_field_widget(entity.cFData , customField) }} - {% else %} -
{{ chill_custom_field_label(customField) }}
-
{{ chill_custom_field_widget(entity.cFData , customField) }}
- {% endif %} - {% endfor %} + {{ chill_custom_fields_group_widget(entity.cFData, entity.cFGroup) }} {{ 'Update the report' | trans }} From 8a7503ce387502a136c88486defb068d572bb643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 26 Oct 2015 21:57:49 +0100 Subject: [PATCH 130/210] add gitlab ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squashed commit of the following: commit ff63a334213c4965e06d33aedb72a03cb79fcc57 Author: Julien Fastré Date: Mon Oct 26 21:19:57 2015 +0100 add gitlab-ci files --- .gitignore | 1 + .gitlab-ci.yml | 17 +++++++++++++++++ .../App/app/config/parameters.gitlab-ci.yml | 7 +++++++ 3 files changed, 25 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml diff --git a/.gitignore b/.gitignore index 30eab8a47..f124436f0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.lock Tests/Fixtures/App/app/config/parameters.yml *~ +auth.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..9aedda5df --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,17 @@ +services: + - chill/database:latest + +before_script: + - composer config github-oauth.github.com $GITHUB_TOKEN + - composer install --no-interaction + - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml + - php Tests/Fixtures/App/app/console --env=test cache:warmup + - php Tests/Fixtures/App/app/console doctrine:migrations:migrate --env=test --no-interaction + - php Tests/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction + +test:php-5.6: + stage: test + script: phpunit --testdox +test:php-7: + stage: test + script: phpunit --testdox diff --git a/Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml b/Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml new file mode 100644 index 000000000..9e3b75daf --- /dev/null +++ b/Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml @@ -0,0 +1,7 @@ +parameters: + database_host: chill__database + database_port: 5432 + database_name: postgres + database_user: postgres + database_password: postgres + locale: fr From ff16ed9b2c6f83fc3b523b72412b06fb06ac2d72 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 30 Oct 2015 16:04:29 +0100 Subject: [PATCH 131/210] Adding refs to the doc & removeing refs to travis in README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e6d3b1a95..992414664 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ ChillReport =========== -The bundle for reports +The bundle for reports. This is a bundle of the Chill project. -[![Build Status](https://travis-ci.org/Chill-project/Report.png)](http://travis-ci.org/#!/Chill-project/Report.png) +Documentation & installation +---------------------------- + +Read documentation here : http://chill.readthedocs.org \ No newline at end of file From 301f35893c2f87e4cc3c174cbeac67eb6a2a0466 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 30 Oct 2015 16:05:00 +0100 Subject: [PATCH 132/210] Removing travis config files --- .travis.yml | 29 ------------------- .../App/app/config/parameters.travis.yml | 7 ----- 2 files changed, 36 deletions(-) delete mode 100644 .travis.yml delete mode 100644 Tests/Fixtures/App/app/config/parameters.travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9fdfae750..000000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: php -php: -- 5.5 -- 5.6 -- hhvm-nightly -matrix: - allow_failures: - - php: hhvm-nightly -addons: - postgresql: '9.3' -sudo: false -install: -- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH -- composer install --dev --no-interaction -- cp Tests/Fixtures/App/app/config/parameters.travis.yml Tests/Fixtures/App/app/config/parameters.yml -before_script: -- psql -c 'create database test0;' -U postgres -- psql -d test0 -c 'CREATE EXTENSION unaccent;' -U postgres -- php Tests/Fixtures/App/app/console --env=test cache:warmup -- php Tests/Fixtures/App/app/console assets:install Tests/Fixtures/App/web -- php Tests/Fixtures/App/app/console doctrine:migrations:migrate --no-interaction -- php Tests/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction -script: phpunit --coverage-text -notifications: - email: - - info@champs-libres.coop -env: - global: - secure: WUAweJ9uyCNVQsv8OOD5jofcxSlRLHbI9HBsDDdSuPVLhCcJCLRdQ312wtn5ckfy3pe+aKaijrM/rhd0NQ6lwCkcYAXcikug9k5tf2BJ0H7AJnqe56/cQSrXvxV8n6L1S2xk4AugG/k6PngZQeca5k/34jJ9ViI06V2+r4UrL7w= diff --git a/Tests/Fixtures/App/app/config/parameters.travis.yml b/Tests/Fixtures/App/app/config/parameters.travis.yml deleted file mode 100644 index 28d5cd26c..000000000 --- a/Tests/Fixtures/App/app/config/parameters.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -parameters: - database_host: 127.0.0.1 - database_port: 5432 - database_name: test0 - database_user: postgres - database_password: postgres - locale: fr \ No newline at end of file From 58cd4be3833c7820d46550d2ab70948c59aacb4e Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 30 Oct 2015 17:12:19 +0100 Subject: [PATCH 133/210] debug flash danger -> error --- Controller/ReportController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index b628808f9..317f71bf9 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -280,7 +280,7 @@ class ReportController extends Controller $this->get('session') - ->getFlashBag()->add('danger', + ->getFlashBag()->add('error', $this->get('translator') ->trans('The form is not valid. The report has not been created !') ); @@ -440,7 +440,7 @@ class ReportController extends Controller $this->get('session') ->getFlashBag() - ->add('danger', + ->add('error', $this->get('translator') ->trans('The form is not valid. The report has not been updated !') ); From e9ef6718a02b8dca07bcf181514d6bbc75d27976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 1 Dec 2015 22:20:29 +0100 Subject: [PATCH 134/210] minimal improvement ref Chill-project/Chill-Report#3 --- Resources/translations/messages.nl.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Resources/translations/messages.nl.yml b/Resources/translations/messages.nl.yml index 046931812..adabc1d1c 100644 --- a/Resources/translations/messages.nl.yml +++ b/Resources/translations/messages.nl.yml @@ -27,3 +27,6 @@ User: Gebruiker 'This is not the report of the person.': "Dit is niet het dossier van deze person" 'You are going to leave a page with unsubmitted data. Are you sure you want to leave ?': 'U bent aan te vertrekken een pagina die veranderdt datas behoudt. Bent u er zeker van dat u wil vertrekken ?' + +#timeline +'%user% has filled a %report_label% report on %date%': %user% heeft een rapport '%report_label%' toegevoegd om %date% From 49339d78fa8252d865076ae4814ac8d1d5d23e50 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 4 Dec 2015 19:39:47 +0100 Subject: [PATCH 135/210] Amelioration UI --- Resources/views/Report/list.html.twig | 4 ++-- Resources/views/Report/view.html.twig | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index 3641564fa..966703d1d 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -37,8 +37,8 @@
- - + + {% endfor %} diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index b344219c9..499ae3d84 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -22,26 +22,23 @@ {% block personcontent %} - - {{ 'Update the report'|trans }} - -

{{ 'Details'|trans }}

+

{{ 'Details'|trans }}

-
{{ 'Person'|trans }}
+
{{ 'Person'|trans }} :
{{ entity.person }}
-
{{ 'Scope'|trans }}
+
{{ 'Scope'|trans }} :
{{ entity.scope.name|localize_translatable_string }}
-
{{ 'Date'|trans }}
+
{{ 'Date'|trans }} :
{{ entity.date|localizeddate('long', 'none') }}
-
{{ 'User'|trans }}
+
{{ 'User'|trans }} :
{{ entity.user }}
-
{{ 'Report type'|trans }}
+
{{ 'Report type'|trans }} :
{{ entity.cFGroup.getName(app.request.locale) }}
{{ chill_custom_fields_group_widget(entity.cFData, entity.cFGroup) }}
- {{ 'Update the report' | trans }} + {{ 'Update the report' | trans }} {% endblock %} From 119b3c0bc191049d4ea6a62fe337a9bf43aaa762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 14 Dec 2015 22:21:18 +0100 Subject: [PATCH 136/210] change config to switch to symfony 2.8 --- Tests/Fixtures/App/app/config/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Fixtures/App/app/config/config.yml b/Tests/Fixtures/App/app/config/config.yml index a9cc85293..6a2be1ca6 100644 --- a/Tests/Fixtures/App/app/config/config.yml +++ b/Tests/Fixtures/App/app/config/config.yml @@ -61,7 +61,7 @@ security: http_basic: ~ form_login: csrf_parameter: _csrf_token - intention: authenticate + csrf_token_id: authenticate csrf_provider: form.csrf_provider logout: ~ From 2c89aa4812f52ef772a0e7931a2dc968fa5590ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 14 Dec 2015 22:55:13 +0100 Subject: [PATCH 137/210] improve ACL on report creation + various UI improvements - show button to update report only to users with correct permissions; - show new page only to users with correct permissions ; - rename scope => circle in column, + translations --- Controller/ReportController.php | 20 ++++++++++++++++++-- Resources/views/Report/list.html.twig | 18 +++++++++++++++--- Resources/views/Report/new.html.twig | 4 +++- Resources/views/Report/view.html.twig | 9 +++++---- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 317f71bf9..0f49e406d 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -70,6 +70,21 @@ class ReportController extends Controller */ public function selectReportTypeAction($person_id, Request $request) { + $em = $this->getDoctrine()->getManager(); + + $person = $em->getRepository('ChillPersonBundle:Person') + ->find($person_id); + + if ($person === NULL) { + throw $this->createNotFoundException('Person not found!'); + } + + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person, 'access denied for person view'); + // check access on report creation for a dummy report + $this->denyAccessUnlessGranted('CHILL_REPORT_CREATE', + (new Report())->setPerson($person), 'access denied for report creation'); + + $cFGroupId = $request->query->get('cFGroup'); if($cFGroupId) { @@ -78,8 +93,6 @@ class ReportController extends Controller array('person_id' => $person_id, 'cf_group_id' => $cFGroupId))); } - $em = $this->getDoctrine()->getManager(); - $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') ->findByEntity('Chill\ReportBundle\Entity\Report'); @@ -210,6 +223,9 @@ class ReportController extends Controller } $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + // check access on report creation for a dummy report + $this->denyAccessUnlessGranted('CHILL_REPORT_CREATE', + (new Report())->setPerson($person), 'access denied for report creation'); if ($cFGroup === NULL){ throw $this->createNotFoundException("custom fields group not found"); diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index 966703d1d..9e0ad5c47 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -26,7 +26,7 @@ - + @@ -37,8 +37,20 @@ - - + {% endfor %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index ca1955301..ab6f44c4a 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -23,7 +23,9 @@ {% block personcontent %} {{ form_start(form) }} - {{ form_widget(form) }} + {{ form_row(form.user) }} + {{ form_row(form.date) }} + {{ form_row(form.scope) }}
diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 499ae3d84..686735448 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -27,8 +27,8 @@
{{ 'Person'|trans }} :
{{ entity.person }}
-
{{ 'Scope'|trans }} :
-
{{ entity.scope.name|localize_translatable_string }}
+
{{ 'Circle'|trans }} :
+
{{ entity.scope.name|localize_translatable_string }}
{{ 'Date'|trans }} :
{{ entity.date|localizeddate('long', 'none') }}
{{ 'User'|trans }} :
@@ -38,7 +38,8 @@ {{ chill_custom_fields_group_widget(entity.cFData, entity.cFGroup) }}
- + + {% if is_granted('CHILL_REPORT_UPDATE', entity) %} {{ 'Update the report' | trans }} - + {% endif %} {% endblock %} From f2cdaaa1a3f28bda2952f77ad620f93694656032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 14 Dec 2015 23:04:22 +0100 Subject: [PATCH 138/210] fix order in report form --- Resources/views/Report/new.html.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index ab6f44c4a..744dca41c 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -26,6 +26,7 @@ {{ form_row(form.user) }} {{ form_row(form.date) }} {{ form_row(form.scope) }} + {{ form_row(form.cFData) }}
From ec838755e1b418407ad8b5f710baf377eaa3d214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 14 Dec 2015 23:06:33 +0100 Subject: [PATCH 139/210] set scope to the up of the form in report edit --- Resources/views/Report/edit.html.twig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index 51ecfaaf8..18009675a 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -23,6 +23,11 @@ {% block personcontent %} {{ form_start(edit_form) }} + {{ form_row(edit_form.user) }} + {{ form_row(edit_form.date) }} + {{ form_row(edit_form.scope) }} + {{ form_row(edit_form.cFData) }} + {{ form_widget(edit_form) }}
From ef718fe93a34f93a4827b3642e5da17c1566f6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 16 Dec 2015 13:19:00 +0100 Subject: [PATCH 140/210] adapt text language in test --- Tests/Controller/ReportControllerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index e5373b339..526097aa8 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -383,7 +383,7 @@ class ReportControllerTest extends WebTestCase $this->assertRegExp(sprintf('|/fr/person/%s/report/[0-9]*/view$|', static::$person->getId(), $reportId), $linkSee[0]->getUri()); - $linkUpdate = $crawler->selectLink('Mettre à jour le rapport')->links(); + $linkUpdate = $crawler->selectLink('Update')->links(); $this->assertGreaterThan(0, count($linkUpdate)); $this->assertRegExp(sprintf('|/fr/person/%s/report/[0-9]*/edit$|', static::$person->getId(), $reportId), $linkUpdate[0]->getUri()); From b672074823c6519bb634e476f747d0f476be9fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Dec 2015 01:45:25 +0100 Subject: [PATCH 141/210] improve report view --- Resources/translations/messages.fr.yml | 5 ++++- Resources/views/Report/view.html.twig | 12 ++++++++---- .../views/Timeline/report_person_context.html.twig | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 9874c8b19..78cd18814 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -9,12 +9,15 @@ 'Report list': 'Liste des rapports' Details: Détails Person: Personne -Scope: Scope +Scope: Cercle Date: Date User: Utilisateur 'Report type': 'Type de rapport' 'View the report': "Voir le rapport" 'Update the report': "Mettre à jour le rapport" +Report data: Données du rapport +'Report view : %name%': 'Rapport : %name%' +Report: Rapport #Flash messages 'Success : report created!': "Succès : le rapport a bien été créé !" diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 686735448..3a6fde97f 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -21,6 +21,8 @@ {% block title %}{{ 'Report view' |trans() }}{% endblock title %} {% block personcontent %} + +

{{ 'Report view : %name%' | trans({ '%name%' : entity.cFGroup.getName|localize_translatable_string } ) }}

{{ 'Details'|trans }}

@@ -33,12 +35,14 @@
{{ entity.date|localizeddate('long', 'none') }}
{{ 'User'|trans }} :
{{ entity.user }}
-
{{ 'Report type'|trans }} :
-
{{ entity.cFGroup.getName(app.request.locale) }}
- - {{ chill_custom_fields_group_widget(entity.cFData, entity.cFGroup) }} + +

{{ 'Report data'|trans }}

+ +
+ {{ chill_custom_fields_group_widget(entity.cFData, entity.cFGroup) }} +
{% if is_granted('CHILL_REPORT_UPDATE', entity) %} {{ 'Update the report' | trans }} {% endif %} diff --git a/Resources/views/Timeline/report_person_context.html.twig b/Resources/views/Timeline/report_person_context.html.twig index 8ac8432f1..bba3714e7 100644 --- a/Resources/views/Timeline/report_person_context.html.twig +++ b/Resources/views/Timeline/report_person_context.html.twig @@ -12,7 +12,7 @@ {% if custom_fields_in_summary|length > 0 %}

-
+
{% for field in custom_fields_in_summary %} {% if field.type == 'title' %} {{ chill_custom_field_widget(report.cFData, field) }} From e939a809b157353b52dc0017884bb7b182a466eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 5 Jan 2016 13:15:35 +0100 Subject: [PATCH 142/210] fix show empty values in timeline --- Resources/config/services.yml | 2 + Timeline/TimelineReportProvider.php | 77 +++++++++++++++++++++++------ 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 326990d35..fec944ff5 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -21,6 +21,8 @@ services: - '@doctrine.orm.entity_manager' - '@chill.main.security.authorization.helper' - '@security.token_storage' + - '@chill.custom_field.helper' + - '%chill_custom_fields.show_empty_values%' tags: - { name: chill.timeline, context: 'person' } diff --git a/Timeline/TimelineReportProvider.php b/Timeline/TimelineReportProvider.php index a4d189212..6c60d222a 100644 --- a/Timeline/TimelineReportProvider.php +++ b/Timeline/TimelineReportProvider.php @@ -28,6 +28,8 @@ use Symfony\Component\Security\Core\Role\Role; use Doctrine\ORM\Mapping\ClassMetadata; use Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Entity\Scope; +use Chill\CustomFieldsBundle\Service\CustomFieldsHelper; +use Chill\ReportBundle\Entity\Report; /** * Provide report for inclusion in timeline @@ -56,8 +58,17 @@ class TimelineReportProvider implements TimelineProviderInterface */ protected $user; + /** + * + * @var CustomFieldsHelper + */ + protected $customFieldsHelper; + + protected $showEmptyValues; + public function __construct(EntityManager $em, AuthorizationHelper $helper, - TokenStorage $storage) + TokenStorage $storage, CustomFieldsHelper $customFieldsHelper, + $showEmptyValues) { $this->em = $em; $this->helper = $helper; @@ -68,6 +79,8 @@ class TimelineReportProvider implements TimelineProviderInterface } $this->user = $storage->getToken()->getUser(); + $this->customFieldsHelper = $customFieldsHelper; + $this->showEmptyValues = $showEmptyValues; } /** @@ -169,30 +182,62 @@ class TimelineReportProvider implements TimelineProviderInterface { $this->checkContext($context); - //gather all custom fields which should appears in summary - $customFieldsInSummary = array(); - if (array_key_exists('summary_fields', $entity->getCFGroup()->getOptions())) { - - foreach ($entity->getCFGroup()->getCustomFields() as $customField) { - if (in_array($customField->getSlug(), - $entity->getCFGroup()->getOptions()['summary_fields'])) { - $customFieldsInSummary[] = $customField; - } - } - } - - - return array( 'template' => 'ChillReportBundle:Timeline:report_person_context.html.twig', 'template_data' => array( 'report' => $entity, - 'custom_fields_in_summary' => $customFieldsInSummary, + 'custom_fields_in_summary' => $this->getFieldsToRender($entity, $context), 'person' => $args['person'], 'user' => $entity->getUser() ) ); } + + protected function getFieldsToRender(Report $entity, $context, array $args = array()) + { + //gather all custom fields which should appears in summary + $gatheredFields = array(); + + if (array_key_exists('summary_fields', $entity->getCFGroup()->getOptions())) { + // keep in memory title + $title = null; + $subtitle = null; + + foreach ($entity->getCFGroup()->getCustomFields() as $customField) { + if (in_array($customField->getSlug(), + $entity->getCFGroup()->getOptions()['summary_fields'])) { + // if we do not want to show empty values + if ($this->showEmptyValues === false) { + if ($customField->getType() === 'title') { + $options = $customField->getOptions(); + switch($options['type']) { + case 'title': $title = $customField; break; + case 'subtitle': $subtitle = $customField; break; + } + } else { + if ($this->customFieldsHelper->isEmptyValue($entity->getCFData(), $customField) + === false) { + if ($title !== NULL) { + $gatheredFields[] = $title; + $title = null; + } + if ($subtitle !== NULL) { + $gatheredFields[] = $subtitle; + $subtitle = null; + } + $gatheredFields[] = $customField; + } + } + } else { + $gatheredFields[] = $customField; + } + } + } + } + + return $gatheredFields; + + } /** * From e6cacb855458fa2087dbdc407a4670441edc0c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 20 Jan 2016 17:39:14 +0100 Subject: [PATCH 143/210] fix tranlsation in tests --- Tests/Controller/ReportControllerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index 526097aa8..682fd7414 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -383,7 +383,7 @@ class ReportControllerTest extends WebTestCase $this->assertRegExp(sprintf('|/fr/person/%s/report/[0-9]*/view$|', static::$person->getId(), $reportId), $linkSee[0]->getUri()); - $linkUpdate = $crawler->selectLink('Update')->links(); + $linkUpdate = $crawler->selectLink('Mettre à jour')->links(); $this->assertGreaterThan(0, count($linkUpdate)); $this->assertRegExp(sprintf('|/fr/person/%s/report/[0-9]*/edit$|', static::$person->getId(), $reportId), $linkUpdate[0]->getUri()); From 0a4b875055b287a644e2d4d57a3884b20821349c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 23 Feb 2016 15:30:43 +0100 Subject: [PATCH 144/210] upgrade dependency on doctrine-migration-bundle to ~1.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 38e26d831..fdeef2ad8 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "chill-project/custom-fields": "dev-master@dev", "chill-project/person": "dev-master", "champs-libres/composer-bundle-migration": "~1.0", - "doctrine/doctrine-migrations-bundle": "dev-master@dev", + "doctrine/doctrine-migrations-bundle": "~1.1", "doctrine/migrations": "~1.0@dev" }, "require-dev": { From c522659f4e7cd4acb49094afbc9d0c83d503d1cb Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 6 May 2016 16:37:33 +0200 Subject: [PATCH 145/210] Improving the timeline UI --- Resources/views/Timeline/report_person_context.html.twig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Resources/views/Timeline/report_person_context.html.twig b/Resources/views/Timeline/report_person_context.html.twig index bba3714e7..e2f64224e 100644 --- a/Resources/views/Timeline/report_person_context.html.twig +++ b/Resources/views/Timeline/report_person_context.html.twig @@ -1,5 +1,5 @@ -
-

{{ 'Report'|trans }}

+
+

{{ report.date|localizeddate('long', 'none') }} / {{ 'Report'|trans }}

{{ '%user% has filled a %report_label% report on %date%'|trans( { @@ -11,7 +11,6 @@
{% if custom_fields_in_summary|length > 0 %}
-
{% for field in custom_fields_in_summary %} {% if field.type == 'title' %} From b396826d8e7a32929a7ba49b5bef235002dde578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 17 Nov 2016 21:59:12 +0100 Subject: [PATCH 146/210] removing testdox for a better understanding of failure message --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9aedda5df..467c15585 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ before_script: test:php-5.6: stage: test - script: phpunit --testdox + script: phpunit test:php-7: stage: test - script: phpunit --testdox + script: phpunit From 8ebacb22acd6aaed9714b2ae4ff9f17bc6ba645e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Nov 2016 22:39:00 +0100 Subject: [PATCH 147/210] adding step to deploy to packagist --- .gitlab-ci.yml | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 467c15585..39b3dea65 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,33 @@ -services: - - chill/database:latest - -before_script: - - composer config github-oauth.github.com $GITHUB_TOKEN - - composer install --no-interaction - - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml - - php Tests/Fixtures/App/app/console --env=test cache:warmup - - php Tests/Fixtures/App/app/console doctrine:migrations:migrate --env=test --no-interaction - - php Tests/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction +.test_definition: &test_definition + services: + - chill/database:latest + + before_script: + - composer config github-oauth.github.com $GITHUB_TOKEN + - composer install --no-interaction + - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml + - php Tests/Fixtures/App/app/console --env=test cache:warmup + - php Tests/Fixtures/App/app/console doctrine:migrations:migrate --env=test --no-interaction + - php Tests/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction test:php-5.6: - stage: test - script: phpunit + stage: test + image: chill/ci-image:php-5.6 + <<: *test_definition + script: phpunit test:php-7: - stage: test - script: phpunit + stage: test + image: chill/ci-image:php-7 + <<: *test_definition + script: phpunit + +deploy-packagist: + stage: deploy + image: chill/ci-image:php-7 + before_script: + # test that PACKAGIST USERNAME and PACKAGIST_TOKEN variable are set + - if [ -z ${PACKAGIST_USERNAME+x} ]; then echo "Please set PACKAGIST_USERNAME variable"; exit -1; fi + - if [ -z ${PACKAGIST_TOKEN+x} ]; then echo "Please set PACKAGIST_TOKEN variable"; exit -1; fi + script: + - STATUSCODE=$(curl -XPOST -H'content-type:application/json' "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_TOKEN" -d"{\"repository\":{\"url\":\"$CI_PROJECT_URL.git\"}}" --silent --output /dev/stderr --write-out "%{http_code}") + - if [ $STATUSCODE = "202" ]; then exit 0; else exit $STATUSCODE; fi From 7d19b4d8b7af554143b76ad71a3e28cd8ed25d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 9 Dec 2016 18:19:17 +0100 Subject: [PATCH 148/210] improve layout of list when no report --- Resources/translations/messages.fr.yml | 1 + Resources/views/Report/list.html.twig | 28 ++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 78cd18814..3d4b97198 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -18,6 +18,7 @@ User: Utilisateur Report data: Données du rapport 'Report view : %name%': 'Rapport : %name%' Report: Rapport +No report registered for this person.: Aucun rapport pour cette personne. #Flash messages 'Success : report created!': "Succès : le rapport a bien été créé !" diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index 9e0ad5c47..9cd095647 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -21,27 +21,35 @@ {% block title %}{{ 'Report list' |trans }}{% endblock title %} {% block personcontent %} + +

{{ 'Report list'|trans }}

+ + {% if reports|length == 0 %} +

+ {{ "No report registered for this person."|trans }} + {{ 'Create a new report'|trans }} +

+ {% else %}
{{ 'Date' | trans }}{{ 'Report type' | trans }}{{ 'Report scope' | trans }}{{ 'Date' | trans }}{{ 'Report type' | trans }}{{ 'Report scope' | trans }}
{% if report.date %}{{ report.date|localizeddate('long', 'none') }}{% endif %} {{ report.cFGroup.getName(app.request.locale) }} {{ report.scope.name|localize_translatable_string }}{{ 'View the report' | trans }}{{ 'Update the report' | trans }}{{ 'View' | trans }}{{ 'Update' | trans }}
{{ 'Date' | trans }} {{ 'Report type' | trans }}{{ 'Report scope' | trans }}{{ 'Circle' | trans }}
{% if report.date %}{{ report.date|localizeddate('long', 'none') }}{% endif %} {{ report.cFGroup.getName(app.request.locale) }} {{ report.scope.name|localize_translatable_string }}{{ 'View' | trans }}{{ 'Update' | trans }} + +
- - + {% for report in reports %} - +
{{ 'Date' | trans }} {{ 'Report type' | trans }} {{ 'Circle' | trans }}{{ 'Actions'|trans }}
{% if report.date %}{{ report.date|localizeddate('long', 'none') }}{% endif %}{{ report.cFGroup.getName(app.request.locale) }}{{ report.cFGroup.getName|localize_translatable_string }} {{ report.scope.name|localize_translatable_string }}
+ + {% endif %} + + + {% endblock %} From 12cef8609fba3085a6e2fa4189ba70a70c93de47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Dec 2016 16:13:13 +0100 Subject: [PATCH 149/210] publishing doc to public api --- .gitlab-ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ apigen.neon | 10 ++++++++++ 2 files changed, 48 insertions(+) create mode 100644 apigen.neon diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39b3dea65..6759e65b9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,12 @@ - php Tests/Fixtures/App/app/console doctrine:migrations:migrate --env=test --no-interaction - php Tests/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction +stages: + - test + - deploy + - build-doc + - deploy-doc + test:php-5.6: stage: test image: chill/ci-image:php-5.6 @@ -31,3 +37,35 @@ deploy-packagist: script: - STATUSCODE=$(curl -XPOST -H'content-type:application/json' "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_TOKEN" -d"{\"repository\":{\"url\":\"$CI_PROJECT_URL.git\"}}" --silent --output /dev/stderr --write-out "%{http_code}") - if [ $STATUSCODE = "202" ]; then exit 0; else exit $STATUSCODE; fi + +# deploy documentation +api-doc-build: + stage: build-doc + environment: api-doc + image: chill/ci-image:php-7 + before_script: + - mkdir api-doc + script: apigen generate --destination api-doc/$CI_BUILD_REF_NAME/$CI_PROJECT_NAME + artifacts: + paths: + - "api-doc/" + name: api + expire_in: '2h' + only: + - master + - tags + +api-doc-deploy: + stage: deploy-doc + image: pallet/swiftclient:latest + before_script: + # test that CONTAINER_API variable is set + - if [ -z ${CONTAINER_API+x} ]; then echo "Please set CONTAINER_API variable"; exit -1; fi + # go to api-doc to have and url with PROJECT/BUILD + - cd api-doc + # upload, and keep files during 1 year + script: "swift upload --header \"X-Delete-After: 31536000\" $CONTAINER_API $CI_BUILD_REF_NAME/$CI_PROJECT_NAME" + only: + - master + - tags + diff --git a/apigen.neon b/apigen.neon new file mode 100644 index 000000000..42552e9f5 --- /dev/null +++ b/apigen.neon @@ -0,0 +1,10 @@ +# configuration for apigen + +source: + - . + +exclude: + - vendor/* + - Test* + +title: Chill Report Bundle From cf823ef45bf1204ce7963ea5130775346c865a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 19 Dec 2016 12:01:22 +0100 Subject: [PATCH 150/210] remove memory_limit during the installation of deps --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6759e65b9..fe90372ed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ before_script: - composer config github-oauth.github.com $GITHUB_TOKEN - - composer install --no-interaction + - php -d memory_limit=-1 /usr/local/bin/composer install --no-interaction - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml - php Tests/Fixtures/App/app/console --env=test cache:warmup - php Tests/Fixtures/App/app/console doctrine:migrations:migrate --env=test --no-interaction From 07b2a0994d268cbdb47a93f16eb4dee8100b0658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Apr 2017 21:50:23 +0200 Subject: [PATCH 151/210] allow hierarchy in roles --- Security/Authorization/ReportVoter.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Security/Authorization/ReportVoter.php b/Security/Authorization/ReportVoter.php index e3218fec7..6ffb9d153 100644 --- a/Security/Authorization/ReportVoter.php +++ b/Security/Authorization/ReportVoter.php @@ -21,14 +21,14 @@ namespace Chill\ReportBundle\Security\Authorization; use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Chill\MainBundle\Security\ProvideRoleInterface; +use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; /** * * * @author Julien Fastré */ -class ReportVoter extends AbstractChillVoter implements ProvideRoleInterface +class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { const CREATE = 'CHILL_REPORT_CREATE'; const SEE = 'CHILL_REPORT_SEE'; @@ -74,5 +74,9 @@ class ReportVoter extends AbstractChillVoter implements ProvideRoleInterface { return array(); } - + + public function getRolesWithHierarchy() + { + return [ 'Report' => $this->getRoles() ]; + } } From 5a3f360822fb650e365c7f6319a6f2fb364e3c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Apr 2017 21:50:32 +0200 Subject: [PATCH 152/210] allow dev packages but prefer stable --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fdeef2ad8..bc6f78a17 100644 --- a/composer.json +++ b/composer.json @@ -48,5 +48,7 @@ }, "extra": { "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations" - } + }, + "minimum-stability": "dev", + "prefer-stable": true } From 332bec6e83e93fd80a392605a4ff0e0f12903482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 22 Jun 2017 23:05:19 +0200 Subject: [PATCH 153/210] fix gitlab tests --- .gitlab-ci.yml | 5 +++-- Controller/ReportController.php | 30 ++++++++++++++++++++++----- Resources/views/Report/list.html.twig | 4 ++++ composer.json | 14 ++++++++----- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe90372ed..ce6e7ca72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,11 +16,12 @@ stages: - build-doc - deploy-doc -test:php-5.6: +test:php-7.1: stage: test - image: chill/ci-image:php-5.6 + image: chill/ci-image:php-7.1 <<: *test_definition script: phpunit + test:php-7: stage: test image: chill/ci-image:php-7 diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 0f49e406d..87c3eaae9 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -52,12 +52,32 @@ class ReportController extends Controller $reachableScopes = $this->get('chill.main.security.authorization.helper') ->getReachableScopes($this->getUser(), new Role('CHILL_REPORT_SEE'), $person->getCenter()); - $reports = $em->getRepository('ChillReportBundle:Report') - ->findBy(array('person' => $person, 'scope' => $reachableScopes)); - + + $total = $em + ->createQuery("SELECT COUNT(r.id) FROM ChillReportBundle:Report r " + . "WHERE r.person = :person AND r.scope IN (:scopes) ") + ->setParameter('person', $person) + ->setParameter('scopes', $reachableScopes) + ->getSingleScalarResult(); + + // get the PaginatorFactory + $paginator = $this->get('chill_main.paginator_factory')->create($total); + + $reports = $em->createQuery('SELECT r + FROM ChillReportBundle:Report r + WHERE r.person = :person AND r.scope IN (:scopes) + ORDER BY r.date DESC') + ->setParameter('person', $person) + ->setParameter('scopes', $reachableScopes) + ->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber()) + ->setMaxResults($paginator->getItemsPerPage()) + ->getResult() + ; + return $this->render('ChillReportBundle:Report:list.html.twig', array( - 'reports' => $reports, - 'person' => $person + 'reports' => $reports, + 'person' => $person, + 'paginator' => $paginator )); } diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index 9cd095647..8849f1832 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -64,6 +64,10 @@ + {% if reports|length < paginator.getTotalItems %} + {{ chill_pagination(paginator) }} + {% endif %} + {% endif %}
    diff --git a/composer.json b/composer.json index bc6f78a17..03d88aa85 100644 --- a/composer.json +++ b/composer.json @@ -30,24 +30,28 @@ "chill-project/person": "dev-master", "champs-libres/composer-bundle-migration": "~1.0", "doctrine/doctrine-migrations-bundle": "~1.1", - "doctrine/migrations": "~1.0@dev" + "doctrine/migrations": "~1.0" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "~2.2", "fzaninotto/faker": "~1", "monolog/monolog": "^1.14", - "symfony/monolog-bundle": "^2.7" + "symfony/monolog-bundle": "^2.7", + "phpunit/phpunit": "~5.0" }, "scripts": { "post-install-cmd": [ - "ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations" + "ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap" ], "post-update-cmd": [ - "ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations" + "ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap" ] }, "extra": { - "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations" + "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations", + "symfony-app-dir": "Tests/Fixtures/App/app" }, "minimum-stability": "dev", "prefer-stable": true From 2145bd2be9d0ab73912b247c1367a20724cedc9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 22 Jun 2017 23:06:07 +0200 Subject: [PATCH 154/210] use downloaded phpunit --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ce6e7ca72..38fe0574e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,13 +20,13 @@ test:php-7.1: stage: test image: chill/ci-image:php-7.1 <<: *test_definition - script: phpunit + script: php vendor/bin/phpunit test:php-7: stage: test image: chill/ci-image:php-7 <<: *test_definition - script: phpunit + script: php vendor/bin/phpunit deploy-packagist: stage: deploy From 4d884c2d3ef3fc033ae497b8ad280a7c762eb2d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 4 Jul 2017 21:32:36 +0200 Subject: [PATCH 155/210] remove tests for export --- Tests/Controller/ReportControllerTest.php | 119 ---------------------- 1 file changed, 119 deletions(-) diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index 682fd7414..5ca7e9847 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -440,123 +440,4 @@ class ReportControllerTest extends WebTestCase ->getDate()); } - /** - * Test that in the general export page there is an Export reports link - * that leads to export/report/select/type - * - * @return \Symfony\Component\DomCrawler\Link The link to the the - * form use for selecting which type of report to export - */ - public function testLinkToTheExportReport() - { - $client = $this->getAuthenticatedClient(); - $crawlerReportExportPage = $client->request('GET', '/fr/export'); - - if (! $client->getResponse()->isSuccessful()) { - var_dump($crawlerReportExportPage->html()); - throw new \RuntimeException('The get request at export page failed'); - } - - $link = $crawlerReportExportPage->selectLink("Export reports")->link(); - $this->assertInstanceOf('Symfony\Component\DomCrawler\Link', $link, - "There is a \"export reports\" link in the export menu"); - - $this->assertContains("export/report/select/type", $link->getUri(), - "The \"export reports\" link in the export menu points to export/report/select/type"); - - return $link; - } - - /** - * Test the export form for selecting the type of report to export : - * - follow the given link ( export/report/select/type ) - * - choose randomly a type of report (CustomFieldsGroup) - * - submit the form - * - * @return Integer The id of the type of report selected (CFGroup) - * @depends testLinkToTheExportReport - */ - public function testFormForExportAction(Link $link) - { - $client = $this->getAuthenticatedClient(); - $crawlerExportReportPage = $client->click($link); - - $form = $crawlerExportReportPage->selectButton("Export this kind of reports")->form(); - - $this->assertInstanceOf('Symfony\Component\DomCrawler\Form', $form, - 'I can see a form with a button "Export this kind of reports" '); - - $this->assertGreaterThan(1, count($form->get(self::REPORT_NAME_FIELD) - ->availableOptionValues()), - "I can choose between report types"); - - $possibleOptionsValue = $form->get(self::REPORT_NAME_FIELD) - ->availableOptionValues(); - - - $cfGroupId = $possibleOptionsValue[array_rand($possibleOptionsValue)]; - - $form->get(self::REPORT_NAME_FIELD)->setValue($cfGroupId); - - $client->submit($form); - - $this->assertTrue($client->getResponse()->isRedirect()); - - $client->followRedirect(); - - return $cfGroupId; - } - - /** - * Test the output of the export action : - * - check if a csv file is well received - * - check if the csv is well formated (if each row has the same number of - * cells) - * - check if the number of data rows (not the header) of the csv file is - * as expected (number of report of this type) - * - * @param Int The id of the type of report selected (CFGroup) - * @depends testFormForExportAction - */ - public function testCSVExportAction($cfGroupId) - { - $client = $this->getAuthenticatedClient(); - - $client->request('GET', 'fr/export/report/cfgroup/'. - static::$group->getId()); - $response = $client->getResponse(); - - $this->assertTrue( - strpos($response->headers->get('Content-Type'),'text/csv') !== false, - 'The csv file is well received'); - - $content = $response->getContent(); - $rows = str_getcsv($content, "\n"); - - $headerRow = array_pop($rows); - $header = str_getcsv($headerRow); - $headerSize = sizeof($header); - $numberOfRows = 0; - - foreach ($rows as $row) { - $rowContent = str_getcsv($row); - - $this->assertTrue( - sizeof($rowContent) == $headerSize, - 'Each row of the csv contains the good number of elements (' - . 'regarding to the first row'); - - $numberOfRows ++; - } - - $cfGroup = static::$em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cfGroupId); - $reports = static::$em->getRepository('ChillReportBundle:Report') - ->findByCFGroup($cfGroup); - - $this->markTestSkipped(); - $this->assertEquals( - $numberOfRows, sizeof($reports), - 'The csv file has a number of row equivalent than the number of reports in the db' - ); - } } From 90d74c609e9c57dff74b486e492f055c5de3f7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 4 Jul 2017 21:43:01 +0200 Subject: [PATCH 156/210] fix css classes in tests --- {Tests => Resources/test}/Fixtures/.DS_Store | Bin .../test}/Fixtures/App/app/AppKernel.php | 0 .../Fixtures/App/app/DoctrineMigrations/.gitignore | 0 .../test}/Fixtures/App/app/config/config.yml | 0 .../test}/Fixtures/App/app/config/config_dev.yml | 0 .../test}/Fixtures/App/app/config/config_test.yml | 0 .../App/app/config/parameters.gitlab-ci.yml | 0 .../Fixtures/App/app/config/parameters.yml.dist | 0 .../test}/Fixtures/App/app/config/routing.yml | 0 {Tests => Resources/test}/Fixtures/App/app/console | 0 .../test}/Fixtures/App/web/.gitignore | 0 .../views/Timeline/report_person_context.html.twig | 2 +- Tests/Search/ReportSearchTest.php | 1 - Tests/Timeline/TimelineProviderTest.php | 8 ++++---- 14 files changed, 5 insertions(+), 6 deletions(-) rename {Tests => Resources/test}/Fixtures/.DS_Store (100%) rename {Tests => Resources/test}/Fixtures/App/app/AppKernel.php (100%) rename {Tests => Resources/test}/Fixtures/App/app/DoctrineMigrations/.gitignore (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/config.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/config_dev.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/config_test.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/parameters.gitlab-ci.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/parameters.yml.dist (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/routing.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/console (100%) rename {Tests => Resources/test}/Fixtures/App/web/.gitignore (100%) diff --git a/Tests/Fixtures/.DS_Store b/Resources/test/Fixtures/.DS_Store similarity index 100% rename from Tests/Fixtures/.DS_Store rename to Resources/test/Fixtures/.DS_Store diff --git a/Tests/Fixtures/App/app/AppKernel.php b/Resources/test/Fixtures/App/app/AppKernel.php similarity index 100% rename from Tests/Fixtures/App/app/AppKernel.php rename to Resources/test/Fixtures/App/app/AppKernel.php diff --git a/Tests/Fixtures/App/app/DoctrineMigrations/.gitignore b/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore similarity index 100% rename from Tests/Fixtures/App/app/DoctrineMigrations/.gitignore rename to Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore diff --git a/Tests/Fixtures/App/app/config/config.yml b/Resources/test/Fixtures/App/app/config/config.yml similarity index 100% rename from Tests/Fixtures/App/app/config/config.yml rename to Resources/test/Fixtures/App/app/config/config.yml diff --git a/Tests/Fixtures/App/app/config/config_dev.yml b/Resources/test/Fixtures/App/app/config/config_dev.yml similarity index 100% rename from Tests/Fixtures/App/app/config/config_dev.yml rename to Resources/test/Fixtures/App/app/config/config_dev.yml diff --git a/Tests/Fixtures/App/app/config/config_test.yml b/Resources/test/Fixtures/App/app/config/config_test.yml similarity index 100% rename from Tests/Fixtures/App/app/config/config_test.yml rename to Resources/test/Fixtures/App/app/config/config_test.yml diff --git a/Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml b/Resources/test/Fixtures/App/app/config/parameters.gitlab-ci.yml similarity index 100% rename from Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml rename to Resources/test/Fixtures/App/app/config/parameters.gitlab-ci.yml diff --git a/Tests/Fixtures/App/app/config/parameters.yml.dist b/Resources/test/Fixtures/App/app/config/parameters.yml.dist similarity index 100% rename from Tests/Fixtures/App/app/config/parameters.yml.dist rename to Resources/test/Fixtures/App/app/config/parameters.yml.dist diff --git a/Tests/Fixtures/App/app/config/routing.yml b/Resources/test/Fixtures/App/app/config/routing.yml similarity index 100% rename from Tests/Fixtures/App/app/config/routing.yml rename to Resources/test/Fixtures/App/app/config/routing.yml diff --git a/Tests/Fixtures/App/app/console b/Resources/test/Fixtures/App/app/console similarity index 100% rename from Tests/Fixtures/App/app/console rename to Resources/test/Fixtures/App/app/console diff --git a/Tests/Fixtures/App/web/.gitignore b/Resources/test/Fixtures/App/web/.gitignore similarity index 100% rename from Tests/Fixtures/App/web/.gitignore rename to Resources/test/Fixtures/App/web/.gitignore diff --git a/Resources/views/Timeline/report_person_context.html.twig b/Resources/views/Timeline/report_person_context.html.twig index e2f64224e..c7b4e5b3f 100644 --- a/Resources/views/Timeline/report_person_context.html.twig +++ b/Resources/views/Timeline/report_person_context.html.twig @@ -1,4 +1,4 @@ -
    +

    {{ report.date|localizeddate('long', 'none') }} / {{ 'Report'|trans }}

    {{ '%user% has filled a %report_label% report on %date%'|trans( diff --git a/Tests/Search/ReportSearchTest.php b/Tests/Search/ReportSearchTest.php index b650c7cea..d4fc0e757 100644 --- a/Tests/Search/ReportSearchTest.php +++ b/Tests/Search/ReportSearchTest.php @@ -64,7 +64,6 @@ class ReportSearchTest extends WebTestCase )); $this->assertTrue($client->getResponse()->isSuccessful()); - $this->assertRegExp('/Charline/', $crawler->text()); $this->assertRegExp('/Situation de logement/i', $crawler->text()); } diff --git a/Tests/Timeline/TimelineProviderTest.php b/Tests/Timeline/TimelineProviderTest.php index 5df8e22fd..830600a6e 100644 --- a/Tests/Timeline/TimelineProviderTest.php +++ b/Tests/Timeline/TimelineProviderTest.php @@ -130,13 +130,13 @@ class TimelineProviderTest extends WebTestCase //performs tests $this->assertTrue($client->getResponse()->isSuccessful(), 'The page timeline is loaded successfully'); - $this->assertGreaterThan(0, $crawler->filter('.report .summary') + $this->assertGreaterThan(0, $crawler->filter('.report_entry .summary') ->count(), 'the page contains a .report .summary element'); - $this->assertContains('blah blah', $crawler->filter('.report .summary') + $this->assertContains('blah blah', $crawler->filter('.report_entry .summary') ->text(), 'the page contains the text "blah blah"'); - $this->assertContains('Propriétaire', $crawler->filter('.report .summary') + $this->assertContains('Propriétaire', $crawler->filter('.report_entry .summary') ->text(), 'the page contains the mention "Propriétaire"'); } @@ -150,7 +150,7 @@ class TimelineProviderTest extends WebTestCase $crawler = $client->request('GET', '/fr/person/'.$this->person->getId() .'/timeline'); - $this->assertEquals(0, $crawler->filter('.report .summary') + $this->assertEquals(0, $crawler->filter('.report_entry .summary') ->count(), 'the page does not contains a .report .summary element'); } From f36ee2f482bb3cafbb606a5c7bfc0b5d8f7ce419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 4 Jul 2017 21:46:15 +0200 Subject: [PATCH 157/210] new architecture for tests --- .gitignore | 1 + .gitlab-ci.yml | 8 +- Resources/test/Fixtures/App/app/autoload.php | 11 + .../test/Fixtures/App/app/bootstrap.php.cache | 1362 +++++++++++++++++ .../Fixtures/App/app/config/parameters.yml | 13 + Resources/test/Fixtures/App/app/console | 18 +- apigen.neon | 1 + composer.json | 5 +- phpunit.xml.dist | 4 +- 9 files changed, 1407 insertions(+), 16 deletions(-) create mode 100644 Resources/test/Fixtures/App/app/autoload.php create mode 100644 Resources/test/Fixtures/App/app/bootstrap.php.cache create mode 100644 Resources/test/Fixtures/App/app/config/parameters.yml diff --git a/.gitignore b/.gitignore index f124436f0..edf97d24e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock Tests/Fixtures/App/app/config/parameters.yml *~ auth.json +/nbproject/private/ \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 38fe0574e..b50126097 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,10 +5,10 @@ before_script: - composer config github-oauth.github.com $GITHUB_TOKEN - php -d memory_limit=-1 /usr/local/bin/composer install --no-interaction - - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml - - php Tests/Fixtures/App/app/console --env=test cache:warmup - - php Tests/Fixtures/App/app/console doctrine:migrations:migrate --env=test --no-interaction - - php Tests/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction + - cp Resources/test/Fixtures/App/app/config/parameters.gitlab-ci.yml Resources/test/Fixtures/App/app/config/parameters.yml + - php Resources/test/Fixtures/App/app/console --env=test cache:warmup + - php Resources/test/Fixtures/App/app/console doctrine:migrations:migrate --env=test --no-interaction + - php Resources/test/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction stages: - test diff --git a/Resources/test/Fixtures/App/app/autoload.php b/Resources/test/Fixtures/App/app/autoload.php new file mode 100644 index 000000000..39dc0e2ba --- /dev/null +++ b/Resources/test/Fixtures/App/app/autoload.php @@ -0,0 +1,11 @@ +parameters = $parameters; +} +public function all() +{ +return $this->parameters; +} +public function keys() +{ +return array_keys($this->parameters); +} +public function replace(array $parameters = array()) +{ +$this->parameters = $parameters; +} +public function add(array $parameters = array()) +{ +$this->parameters = array_replace($this->parameters, $parameters); +} +public function get($key, $default = null, $deep = false) +{ +if ($deep) { +@trigger_error('Using paths to find deeper items in '.__METHOD__.' is deprecated since version 2.8 and will be removed in 3.0. Filter the returned value in your own code instead.', E_USER_DEPRECATED); +} +if (!$deep || false === $pos = strpos($key,'[')) { +return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default; +} +$root = substr($key, 0, $pos); +if (!array_key_exists($root, $this->parameters)) { +return $default; +} +$value = $this->parameters[$root]; +$currentKey = null; +for ($i = $pos, $c = strlen($key); $i < $c; ++$i) { +$char = $key[$i]; +if ('['=== $char) { +if (null !== $currentKey) { +throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "[" at position %d.', $i)); +} +$currentKey =''; +} elseif (']'=== $char) { +if (null === $currentKey) { +throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "]" at position %d.', $i)); +} +if (!is_array($value) || !array_key_exists($currentKey, $value)) { +return $default; +} +$value = $value[$currentKey]; +$currentKey = null; +} else { +if (null === $currentKey) { +throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "%s" at position %d.', $char, $i)); +} +$currentKey .= $char; +} +} +if (null !== $currentKey) { +throw new \InvalidArgumentException('Malformed path. Path must end with "]".'); +} +return $value; +} +public function set($key, $value) +{ +$this->parameters[$key] = $value; +} +public function has($key) +{ +return array_key_exists($key, $this->parameters); +} +public function remove($key) +{ +unset($this->parameters[$key]); +} +public function getAlpha($key, $default ='', $deep = false) +{ +return preg_replace('/[^[:alpha:]]/','', $this->get($key, $default, $deep)); +} +public function getAlnum($key, $default ='', $deep = false) +{ +return preg_replace('/[^[:alnum:]]/','', $this->get($key, $default, $deep)); +} +public function getDigits($key, $default ='', $deep = false) +{ +return str_replace(array('-','+'),'', $this->filter($key, $default, FILTER_SANITIZE_NUMBER_INT, array(), $deep)); +} +public function getInt($key, $default = 0, $deep = false) +{ +return (int) $this->get($key, $default, $deep); +} +public function getBoolean($key, $default = false, $deep = false) +{ +return $this->filter($key, $default, FILTER_VALIDATE_BOOLEAN, array(), $deep); +} +public function filter($key, $default = null, $filter = FILTER_DEFAULT, $options = array(), $deep = false) +{ +static $filters = null; +if (null === $filters) { +foreach (filter_list() as $tmp) { +$filters[filter_id($tmp)] = 1; +} +} +if (is_bool($filter) || !isset($filters[$filter]) || is_array($deep)) { +@trigger_error('Passing the $deep boolean as 3rd argument to the '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Remove it altogether as the $deep argument will be removed in 3.0.', E_USER_DEPRECATED); +$tmp = $deep; +$deep = $filter; +$filter = $options; +$options = $tmp; +} +$value = $this->get($key, $default, $deep); +if (!is_array($options) && $options) { +$options = array('flags'=> $options); +} +if (is_array($value) && !isset($options['flags'])) { +$options['flags'] = FILTER_REQUIRE_ARRAY; +} +return filter_var($value, $filter, $options); +} +public function getIterator() +{ +return new \ArrayIterator($this->parameters); +} +public function count() +{ +return count($this->parameters); +} +} +} +namespace Symfony\Component\HttpFoundation +{ +class HeaderBag implements \IteratorAggregate, \Countable +{ +protected $headers = array(); +protected $cacheControl = array(); +public function __construct(array $headers = array()) +{ +foreach ($headers as $key => $values) { +$this->set($key, $values); +} +} +public function __toString() +{ +if (!$this->headers) { +return''; +} +$max = max(array_map('strlen', array_keys($this->headers))) + 1; +$content =''; +ksort($this->headers); +foreach ($this->headers as $name => $values) { +$name = implode('-', array_map('ucfirst', explode('-', $name))); +foreach ($values as $value) { +$content .= sprintf("%-{$max}s %s\r\n", $name.':', $value); +} +} +return $content; +} +public function all() +{ +return $this->headers; +} +public function keys() +{ +return array_keys($this->headers); +} +public function replace(array $headers = array()) +{ +$this->headers = array(); +$this->add($headers); +} +public function add(array $headers) +{ +foreach ($headers as $key => $values) { +$this->set($key, $values); +} +} +public function get($key, $default = null, $first = true) +{ +$key = str_replace('_','-', strtolower($key)); +if (!array_key_exists($key, $this->headers)) { +if (null === $default) { +return $first ? null : array(); +} +return $first ? $default : array($default); +} +if ($first) { +return count($this->headers[$key]) ? $this->headers[$key][0] : $default; +} +return $this->headers[$key]; +} +public function set($key, $values, $replace = true) +{ +$key = str_replace('_','-', strtolower($key)); +$values = array_values((array) $values); +if (true === $replace || !isset($this->headers[$key])) { +$this->headers[$key] = $values; +} else { +$this->headers[$key] = array_merge($this->headers[$key], $values); +} +if ('cache-control'=== $key) { +$this->cacheControl = $this->parseCacheControl($values[0]); +} +} +public function has($key) +{ +return array_key_exists(str_replace('_','-', strtolower($key)), $this->headers); +} +public function contains($key, $value) +{ +return in_array($value, $this->get($key, null, false)); +} +public function remove($key) +{ +$key = str_replace('_','-', strtolower($key)); +unset($this->headers[$key]); +if ('cache-control'=== $key) { +$this->cacheControl = array(); +} +} +public function getDate($key, \DateTime $default = null) +{ +if (null === $value = $this->get($key)) { +return $default; +} +if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) { +throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value)); +} +return $date; +} +public function addCacheControlDirective($key, $value = true) +{ +$this->cacheControl[$key] = $value; +$this->set('Cache-Control', $this->getCacheControlHeader()); +} +public function hasCacheControlDirective($key) +{ +return array_key_exists($key, $this->cacheControl); +} +public function getCacheControlDirective($key) +{ +return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; +} +public function removeCacheControlDirective($key) +{ +unset($this->cacheControl[$key]); +$this->set('Cache-Control', $this->getCacheControlHeader()); +} +public function getIterator() +{ +return new \ArrayIterator($this->headers); +} +public function count() +{ +return count($this->headers); +} +protected function getCacheControlHeader() +{ +$parts = array(); +ksort($this->cacheControl); +foreach ($this->cacheControl as $key => $value) { +if (true === $value) { +$parts[] = $key; +} else { +if (preg_match('#[^a-zA-Z0-9._-]#', $value)) { +$value ='"'.$value.'"'; +} +$parts[] = "$key=$value"; +} +} +return implode(', ', $parts); +} +protected function parseCacheControl($header) +{ +$cacheControl = array(); +preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER); +foreach ($matches as $match) { +$cacheControl[strtolower($match[1])] = isset($match[3]) ? $match[3] : (isset($match[2]) ? $match[2] : true); +} +return $cacheControl; +} +} +} +namespace Symfony\Component\HttpFoundation +{ +use Symfony\Component\HttpFoundation\File\UploadedFile; +class FileBag extends ParameterBag +{ +private static $fileKeys = array('error','name','size','tmp_name','type'); +public function __construct(array $parameters = array()) +{ +$this->replace($parameters); +} +public function replace(array $files = array()) +{ +$this->parameters = array(); +$this->add($files); +} +public function set($key, $value) +{ +if (!is_array($value) && !$value instanceof UploadedFile) { +throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.'); +} +parent::set($key, $this->convertFileInformation($value)); +} +public function add(array $files = array()) +{ +foreach ($files as $key => $file) { +$this->set($key, $file); +} +} +protected function convertFileInformation($file) +{ +if ($file instanceof UploadedFile) { +return $file; +} +$file = $this->fixPhpFilesArray($file); +if (is_array($file)) { +$keys = array_keys($file); +sort($keys); +if ($keys == self::$fileKeys) { +if (UPLOAD_ERR_NO_FILE == $file['error']) { +$file = null; +} else { +$file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']); +} +} else { +$file = array_map(array($this,'convertFileInformation'), $file); +} +} +return $file; +} +protected function fixPhpFilesArray($data) +{ +if (!is_array($data)) { +return $data; +} +$keys = array_keys($data); +sort($keys); +if (self::$fileKeys != $keys || !isset($data['name']) || !is_array($data['name'])) { +return $data; +} +$files = $data; +foreach (self::$fileKeys as $k) { +unset($files[$k]); +} +foreach ($data['name'] as $key => $name) { +$files[$key] = $this->fixPhpFilesArray(array('error'=> $data['error'][$key],'name'=> $name,'type'=> $data['type'][$key],'tmp_name'=> $data['tmp_name'][$key],'size'=> $data['size'][$key], +)); +} +return $files; +} +} +} +namespace Symfony\Component\HttpFoundation +{ +class ServerBag extends ParameterBag +{ +public function getHeaders() +{ +$headers = array(); +$contentHeaders = array('CONTENT_LENGTH'=> true,'CONTENT_MD5'=> true,'CONTENT_TYPE'=> true); +foreach ($this->parameters as $key => $value) { +if (0 === strpos($key,'HTTP_')) { +$headers[substr($key, 5)] = $value; +} +elseif (isset($contentHeaders[$key])) { +$headers[$key] = $value; +} +} +if (isset($this->parameters['PHP_AUTH_USER'])) { +$headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER']; +$headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] :''; +} else { +$authorizationHeader = null; +if (isset($this->parameters['HTTP_AUTHORIZATION'])) { +$authorizationHeader = $this->parameters['HTTP_AUTHORIZATION']; +} elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) { +$authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION']; +} +if (null !== $authorizationHeader) { +if (0 === stripos($authorizationHeader,'basic ')) { +$exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2); +if (count($exploded) == 2) { +list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded; +} +} elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader,'digest '))) { +$headers['PHP_AUTH_DIGEST'] = $authorizationHeader; +$this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader; +} elseif (0 === stripos($authorizationHeader,'bearer ')) { +$headers['AUTHORIZATION'] = $authorizationHeader; +} +} +} +if (isset($headers['AUTHORIZATION'])) { +return $headers; +} +if (isset($headers['PHP_AUTH_USER'])) { +$headers['AUTHORIZATION'] ='Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']); +} elseif (isset($headers['PHP_AUTH_DIGEST'])) { +$headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST']; +} +return $headers; +} +} +} +namespace Symfony\Component\HttpFoundation +{ +use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException; +use Symfony\Component\HttpFoundation\Session\SessionInterface; +class Request +{ +const HEADER_FORWARDED ='forwarded'; +const HEADER_CLIENT_IP ='client_ip'; +const HEADER_CLIENT_HOST ='client_host'; +const HEADER_CLIENT_PROTO ='client_proto'; +const HEADER_CLIENT_PORT ='client_port'; +const METHOD_HEAD ='HEAD'; +const METHOD_GET ='GET'; +const METHOD_POST ='POST'; +const METHOD_PUT ='PUT'; +const METHOD_PATCH ='PATCH'; +const METHOD_DELETE ='DELETE'; +const METHOD_PURGE ='PURGE'; +const METHOD_OPTIONS ='OPTIONS'; +const METHOD_TRACE ='TRACE'; +const METHOD_CONNECT ='CONNECT'; +protected static $trustedProxies = array(); +protected static $trustedHostPatterns = array(); +protected static $trustedHosts = array(); +protected static $trustedHeaders = array( +self::HEADER_FORWARDED =>'FORWARDED', +self::HEADER_CLIENT_IP =>'X_FORWARDED_FOR', +self::HEADER_CLIENT_HOST =>'X_FORWARDED_HOST', +self::HEADER_CLIENT_PROTO =>'X_FORWARDED_PROTO', +self::HEADER_CLIENT_PORT =>'X_FORWARDED_PORT', +); +protected static $httpMethodParameterOverride = false; +public $attributes; +public $request; +public $query; +public $server; +public $files; +public $cookies; +public $headers; +protected $content; +protected $languages; +protected $charsets; +protected $encodings; +protected $acceptableContentTypes; +protected $pathInfo; +protected $requestUri; +protected $baseUrl; +protected $basePath; +protected $method; +protected $format; +protected $session; +protected $locale; +protected $defaultLocale ='en'; +protected static $formats; +protected static $requestFactory; +private $isForwardedValid = true; +private static $forwardedParams = array( +self::HEADER_CLIENT_IP =>'for', +self::HEADER_CLIENT_HOST =>'host', +self::HEADER_CLIENT_PROTO =>'proto', +self::HEADER_CLIENT_PORT =>'host', +); +public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) +{ +$this->initialize($query, $request, $attributes, $cookies, $files, $server, $content); +} +public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) +{ +$this->request = new ParameterBag($request); +$this->query = new ParameterBag($query); +$this->attributes = new ParameterBag($attributes); +$this->cookies = new ParameterBag($cookies); +$this->files = new FileBag($files); +$this->server = new ServerBag($server); +$this->headers = new HeaderBag($this->server->getHeaders()); +$this->content = $content; +$this->languages = null; +$this->charsets = null; +$this->encodings = null; +$this->acceptableContentTypes = null; +$this->pathInfo = null; +$this->requestUri = null; +$this->baseUrl = null; +$this->basePath = null; +$this->method = null; +$this->format = null; +} +public static function createFromGlobals() +{ +$server = $_SERVER; +if ('cli-server'=== PHP_SAPI) { +if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) { +$server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH']; +} +if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) { +$server['CONTENT_TYPE'] = $_SERVER['HTTP_CONTENT_TYPE']; +} +} +$request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $server); +if (0 === strpos($request->headers->get('CONTENT_TYPE'),'application/x-www-form-urlencoded') +&& in_array(strtoupper($request->server->get('REQUEST_METHOD','GET')), array('PUT','DELETE','PATCH')) +) { +parse_str($request->getContent(), $data); +$request->request = new ParameterBag($data); +} +return $request; +} +public static function create($uri, $method ='GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null) +{ +$server = array_replace(array('SERVER_NAME'=>'localhost','SERVER_PORT'=> 80,'HTTP_HOST'=>'localhost','HTTP_USER_AGENT'=>'Symfony/2.X','HTTP_ACCEPT'=>'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','HTTP_ACCEPT_LANGUAGE'=>'en-us,en;q=0.5','HTTP_ACCEPT_CHARSET'=>'ISO-8859-1,utf-8;q=0.7,*;q=0.7','REMOTE_ADDR'=>'127.0.0.1','SCRIPT_NAME'=>'','SCRIPT_FILENAME'=>'','SERVER_PROTOCOL'=>'HTTP/1.1','REQUEST_TIME'=> time(), +), $server); +$server['PATH_INFO'] =''; +$server['REQUEST_METHOD'] = strtoupper($method); +$components = parse_url($uri); +if (isset($components['host'])) { +$server['SERVER_NAME'] = $components['host']; +$server['HTTP_HOST'] = $components['host']; +} +if (isset($components['scheme'])) { +if ('https'=== $components['scheme']) { +$server['HTTPS'] ='on'; +$server['SERVER_PORT'] = 443; +} else { +unset($server['HTTPS']); +$server['SERVER_PORT'] = 80; +} +} +if (isset($components['port'])) { +$server['SERVER_PORT'] = $components['port']; +$server['HTTP_HOST'] = $server['HTTP_HOST'].':'.$components['port']; +} +if (isset($components['user'])) { +$server['PHP_AUTH_USER'] = $components['user']; +} +if (isset($components['pass'])) { +$server['PHP_AUTH_PW'] = $components['pass']; +} +if (!isset($components['path'])) { +$components['path'] ='/'; +} +switch (strtoupper($method)) { +case'POST': +case'PUT': +case'DELETE': +if (!isset($server['CONTENT_TYPE'])) { +$server['CONTENT_TYPE'] ='application/x-www-form-urlencoded'; +} +case'PATCH': +$request = $parameters; +$query = array(); +break; +default: +$request = array(); +$query = $parameters; +break; +} +$queryString =''; +if (isset($components['query'])) { +parse_str(html_entity_decode($components['query']), $qs); +if ($query) { +$query = array_replace($qs, $query); +$queryString = http_build_query($query,'','&'); +} else { +$query = $qs; +$queryString = $components['query']; +} +} elseif ($query) { +$queryString = http_build_query($query,'','&'); +} +$server['REQUEST_URI'] = $components['path'].(''!== $queryString ?'?'.$queryString :''); +$server['QUERY_STRING'] = $queryString; +return self::createRequestFromFactory($query, $request, array(), $cookies, $files, $server, $content); +} +public static function setFactory($callable) +{ +self::$requestFactory = $callable; +} +public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) +{ +$dup = clone $this; +if ($query !== null) { +$dup->query = new ParameterBag($query); +} +if ($request !== null) { +$dup->request = new ParameterBag($request); +} +if ($attributes !== null) { +$dup->attributes = new ParameterBag($attributes); +} +if ($cookies !== null) { +$dup->cookies = new ParameterBag($cookies); +} +if ($files !== null) { +$dup->files = new FileBag($files); +} +if ($server !== null) { +$dup->server = new ServerBag($server); +$dup->headers = new HeaderBag($dup->server->getHeaders()); +} +$dup->languages = null; +$dup->charsets = null; +$dup->encodings = null; +$dup->acceptableContentTypes = null; +$dup->pathInfo = null; +$dup->requestUri = null; +$dup->baseUrl = null; +$dup->basePath = null; +$dup->method = null; +$dup->format = null; +if (!$dup->get('_format') && $this->get('_format')) { +$dup->attributes->set('_format', $this->get('_format')); +} +if (!$dup->getRequestFormat(null)) { +$dup->setRequestFormat($this->getRequestFormat(null)); +} +return $dup; +} +public function __clone() +{ +$this->query = clone $this->query; +$this->request = clone $this->request; +$this->attributes = clone $this->attributes; +$this->cookies = clone $this->cookies; +$this->files = clone $this->files; +$this->server = clone $this->server; +$this->headers = clone $this->headers; +} +public function __toString() +{ +try { +$content = $this->getContent(); +} catch (\LogicException $e) { +return trigger_error($e, E_USER_ERROR); +} +return +sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n". +$this->headers."\r\n". +$content; +} +public function overrideGlobals() +{ +$this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), null,'&'))); +$_GET = $this->query->all(); +$_POST = $this->request->all(); +$_SERVER = $this->server->all(); +$_COOKIE = $this->cookies->all(); +foreach ($this->headers->all() as $key => $value) { +$key = strtoupper(str_replace('-','_', $key)); +if (in_array($key, array('CONTENT_TYPE','CONTENT_LENGTH'))) { +$_SERVER[$key] = implode(', ', $value); +} else { +$_SERVER['HTTP_'.$key] = implode(', ', $value); +} +} +$request = array('g'=> $_GET,'p'=> $_POST,'c'=> $_COOKIE); +$requestOrder = ini_get('request_order') ?: ini_get('variables_order'); +$requestOrder = preg_replace('#[^cgp]#','', strtolower($requestOrder)) ?:'gp'; +$_REQUEST = array(); +foreach (str_split($requestOrder) as $order) { +$_REQUEST = array_merge($_REQUEST, $request[$order]); +} +} +public static function setTrustedProxies(array $proxies) +{ +self::$trustedProxies = $proxies; +} +public static function getTrustedProxies() +{ +return self::$trustedProxies; +} +public static function setTrustedHosts(array $hostPatterns) +{ +self::$trustedHostPatterns = array_map(function ($hostPattern) { +return sprintf('#%s#i', $hostPattern); +}, $hostPatterns); +self::$trustedHosts = array(); +} +public static function getTrustedHosts() +{ +return self::$trustedHostPatterns; +} +public static function setTrustedHeaderName($key, $value) +{ +if (!array_key_exists($key, self::$trustedHeaders)) { +throw new \InvalidArgumentException(sprintf('Unable to set the trusted header name for key "%s".', $key)); +} +self::$trustedHeaders[$key] = $value; +} +public static function getTrustedHeaderName($key) +{ +if (!array_key_exists($key, self::$trustedHeaders)) { +throw new \InvalidArgumentException(sprintf('Unable to get the trusted header name for key "%s".', $key)); +} +return self::$trustedHeaders[$key]; +} +public static function normalizeQueryString($qs) +{ +if (''== $qs) { +return''; +} +$parts = array(); +$order = array(); +foreach (explode('&', $qs) as $param) { +if (''=== $param ||'='=== $param[0]) { +continue; +} +$keyValuePair = explode('=', $param, 2); +$parts[] = isset($keyValuePair[1]) ? +rawurlencode(urldecode($keyValuePair[0])).'='.rawurlencode(urldecode($keyValuePair[1])) : +rawurlencode(urldecode($keyValuePair[0])); +$order[] = urldecode($keyValuePair[0]); +} +array_multisort($order, SORT_ASC, $parts); +return implode('&', $parts); +} +public static function enableHttpMethodParameterOverride() +{ +self::$httpMethodParameterOverride = true; +} +public static function getHttpMethodParameterOverride() +{ +return self::$httpMethodParameterOverride; +} +public function get($key, $default = null, $deep = false) +{ +if ($deep) { +@trigger_error('Using paths to find deeper items in '.__METHOD__.' is deprecated since version 2.8 and will be removed in 3.0. Filter the returned value in your own code instead.', E_USER_DEPRECATED); +} +if ($this !== $result = $this->query->get($key, $this, $deep)) { +return $result; +} +if ($this !== $result = $this->attributes->get($key, $this, $deep)) { +return $result; +} +if ($this !== $result = $this->request->get($key, $this, $deep)) { +return $result; +} +return $default; +} +public function getSession() +{ +return $this->session; +} +public function hasPreviousSession() +{ +return $this->hasSession() && $this->cookies->has($this->session->getName()); +} +public function hasSession() +{ +return null !== $this->session; +} +public function setSession(SessionInterface $session) +{ +$this->session = $session; +} +public function getClientIps() +{ +$ip = $this->server->get('REMOTE_ADDR'); +if (!$this->isFromTrustedProxy()) { +return array($ip); +} +return $this->getTrustedValues(self::HEADER_CLIENT_IP, $ip) ?: array($ip); +} +public function getClientIp() +{ +$ipAddresses = $this->getClientIps(); +return $ipAddresses[0]; +} +public function getScriptName() +{ +return $this->server->get('SCRIPT_NAME', $this->server->get('ORIG_SCRIPT_NAME','')); +} +public function getPathInfo() +{ +if (null === $this->pathInfo) { +$this->pathInfo = $this->preparePathInfo(); +} +return $this->pathInfo; +} +public function getBasePath() +{ +if (null === $this->basePath) { +$this->basePath = $this->prepareBasePath(); +} +return $this->basePath; +} +public function getBaseUrl() +{ +if (null === $this->baseUrl) { +$this->baseUrl = $this->prepareBaseUrl(); +} +return $this->baseUrl; +} +public function getScheme() +{ +return $this->isSecure() ?'https':'http'; +} +public function getPort() +{ +if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_CLIENT_PORT)) { +$host = $host[0]; +} elseif ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_CLIENT_HOST)) { +$host = $host[0]; +} elseif (!$host = $this->headers->get('HOST')) { +return $this->server->get('SERVER_PORT'); +} +if ($host[0] ==='[') { +$pos = strpos($host,':', strrpos($host,']')); +} else { +$pos = strrpos($host,':'); +} +if (false !== $pos) { +return (int) substr($host, $pos + 1); +} +return'https'=== $this->getScheme() ? 443 : 80; +} +public function getUser() +{ +return $this->headers->get('PHP_AUTH_USER'); +} +public function getPassword() +{ +return $this->headers->get('PHP_AUTH_PW'); +} +public function getUserInfo() +{ +$userinfo = $this->getUser(); +$pass = $this->getPassword(); +if (''!= $pass) { +$userinfo .= ":$pass"; +} +return $userinfo; +} +public function getHttpHost() +{ +$scheme = $this->getScheme(); +$port = $this->getPort(); +if (('http'== $scheme && $port == 80) || ('https'== $scheme && $port == 443)) { +return $this->getHost(); +} +return $this->getHost().':'.$port; +} +public function getRequestUri() +{ +if (null === $this->requestUri) { +$this->requestUri = $this->prepareRequestUri(); +} +return $this->requestUri; +} +public function getSchemeAndHttpHost() +{ +return $this->getScheme().'://'.$this->getHttpHost(); +} +public function getUri() +{ +if (null !== $qs = $this->getQueryString()) { +$qs ='?'.$qs; +} +return $this->getSchemeAndHttpHost().$this->getBaseUrl().$this->getPathInfo().$qs; +} +public function getUriForPath($path) +{ +return $this->getSchemeAndHttpHost().$this->getBaseUrl().$path; +} +public function getRelativeUriForPath($path) +{ +if (!isset($path[0]) ||'/'!== $path[0]) { +return $path; +} +if ($path === $basePath = $this->getPathInfo()) { +return''; +} +$sourceDirs = explode('/', isset($basePath[0]) &&'/'=== $basePath[0] ? substr($basePath, 1) : $basePath); +$targetDirs = explode('/', isset($path[0]) &&'/'=== $path[0] ? substr($path, 1) : $path); +array_pop($sourceDirs); +$targetFile = array_pop($targetDirs); +foreach ($sourceDirs as $i => $dir) { +if (isset($targetDirs[$i]) && $dir === $targetDirs[$i]) { +unset($sourceDirs[$i], $targetDirs[$i]); +} else { +break; +} +} +$targetDirs[] = $targetFile; +$path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs); +return !isset($path[0]) ||'/'=== $path[0] +|| false !== ($colonPos = strpos($path,':')) && ($colonPos < ($slashPos = strpos($path,'/')) || false === $slashPos) +? "./$path" : $path; +} +public function getQueryString() +{ +$qs = static::normalizeQueryString($this->server->get('QUERY_STRING')); +return''=== $qs ? null : $qs; +} +public function isSecure() +{ +if ($this->isFromTrustedProxy() && $proto = $this->getTrustedValues(self::HEADER_CLIENT_PROTO)) { +return in_array(strtolower($proto[0]), array('https','on','ssl','1'), true); +} +$https = $this->server->get('HTTPS'); +return !empty($https) &&'off'!== strtolower($https); +} +public function getHost() +{ +if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_CLIENT_HOST)) { +$host = $host[0]; +} elseif (!$host = $this->headers->get('HOST')) { +if (!$host = $this->server->get('SERVER_NAME')) { +$host = $this->server->get('SERVER_ADDR',''); +} +} +$host = strtolower(preg_replace('/:\d+$/','', trim($host))); +if ($host &&''!== preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/','', $host)) { +throw new \UnexpectedValueException(sprintf('Invalid Host "%s"', $host)); +} +if (count(self::$trustedHostPatterns) > 0) { +if (in_array($host, self::$trustedHosts)) { +return $host; +} +foreach (self::$trustedHostPatterns as $pattern) { +if (preg_match($pattern, $host)) { +self::$trustedHosts[] = $host; +return $host; +} +} +throw new \UnexpectedValueException(sprintf('Untrusted Host "%s"', $host)); +} +return $host; +} +public function setMethod($method) +{ +$this->method = null; +$this->server->set('REQUEST_METHOD', $method); +} +public function getMethod() +{ +if (null === $this->method) { +$this->method = strtoupper($this->server->get('REQUEST_METHOD','GET')); +if ('POST'=== $this->method) { +if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) { +$this->method = strtoupper($method); +} elseif (self::$httpMethodParameterOverride) { +$this->method = strtoupper($this->request->get('_method', $this->query->get('_method','POST'))); +} +} +} +return $this->method; +} +public function getRealMethod() +{ +return strtoupper($this->server->get('REQUEST_METHOD','GET')); +} +public function getMimeType($format) +{ +if (null === static::$formats) { +static::initializeFormats(); +} +return isset(static::$formats[$format]) ? static::$formats[$format][0] : null; +} +public function getFormat($mimeType) +{ +$canonicalMimeType = null; +if (false !== $pos = strpos($mimeType,';')) { +$canonicalMimeType = substr($mimeType, 0, $pos); +} +if (null === static::$formats) { +static::initializeFormats(); +} +foreach (static::$formats as $format => $mimeTypes) { +if (in_array($mimeType, (array) $mimeTypes)) { +return $format; +} +if (null !== $canonicalMimeType && in_array($canonicalMimeType, (array) $mimeTypes)) { +return $format; +} +} +} +public function setFormat($format, $mimeTypes) +{ +if (null === static::$formats) { +static::initializeFormats(); +} +static::$formats[$format] = is_array($mimeTypes) ? $mimeTypes : array($mimeTypes); +} +public function getRequestFormat($default ='html') +{ +if (null === $this->format) { +$this->format = $this->get('_format'); +} +return null === $this->format ? $default : $this->format; +} +public function setRequestFormat($format) +{ +$this->format = $format; +} +public function getContentType() +{ +return $this->getFormat($this->headers->get('CONTENT_TYPE')); +} +public function setDefaultLocale($locale) +{ +$this->defaultLocale = $locale; +if (null === $this->locale) { +$this->setPhpDefaultLocale($locale); +} +} +public function getDefaultLocale() +{ +return $this->defaultLocale; +} +public function setLocale($locale) +{ +$this->setPhpDefaultLocale($this->locale = $locale); +} +public function getLocale() +{ +return null === $this->locale ? $this->defaultLocale : $this->locale; +} +public function isMethod($method) +{ +return $this->getMethod() === strtoupper($method); +} +public function isMethodSafe() +{ +return in_array($this->getMethod(), 0 < func_num_args() && !func_get_arg(0) ? array('GET','HEAD','OPTIONS','TRACE') : array('GET','HEAD')); +} +public function isMethodCacheable() +{ +return in_array($this->getMethod(), array('GET','HEAD')); +} +public function getContent($asResource = false) +{ +$currentContentIsResource = is_resource($this->content); +if (\PHP_VERSION_ID < 50600 && false === $this->content) { +throw new \LogicException('getContent() can only be called once when using the resource return type and PHP below 5.6.'); +} +if (true === $asResource) { +if ($currentContentIsResource) { +rewind($this->content); +return $this->content; +} +if (is_string($this->content)) { +$resource = fopen('php://temp','r+'); +fwrite($resource, $this->content); +rewind($resource); +return $resource; +} +$this->content = false; +return fopen('php://input','rb'); +} +if ($currentContentIsResource) { +rewind($this->content); +return stream_get_contents($this->content); +} +if (null === $this->content || false === $this->content) { +$this->content = file_get_contents('php://input'); +} +return $this->content; +} +public function getETags() +{ +return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, PREG_SPLIT_NO_EMPTY); +} +public function isNoCache() +{ +return $this->headers->hasCacheControlDirective('no-cache') ||'no-cache'== $this->headers->get('Pragma'); +} +public function getPreferredLanguage(array $locales = null) +{ +$preferredLanguages = $this->getLanguages(); +if (empty($locales)) { +return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null; +} +if (!$preferredLanguages) { +return $locales[0]; +} +$extendedPreferredLanguages = array(); +foreach ($preferredLanguages as $language) { +$extendedPreferredLanguages[] = $language; +if (false !== $position = strpos($language,'_')) { +$superLanguage = substr($language, 0, $position); +if (!in_array($superLanguage, $preferredLanguages)) { +$extendedPreferredLanguages[] = $superLanguage; +} +} +} +$preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales)); +return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0]; +} +public function getLanguages() +{ +if (null !== $this->languages) { +return $this->languages; +} +$languages = AcceptHeader::fromString($this->headers->get('Accept-Language'))->all(); +$this->languages = array(); +foreach ($languages as $lang => $acceptHeaderItem) { +if (false !== strpos($lang,'-')) { +$codes = explode('-', $lang); +if ('i'=== $codes[0]) { +if (count($codes) > 1) { +$lang = $codes[1]; +} +} else { +for ($i = 0, $max = count($codes); $i < $max; ++$i) { +if ($i === 0) { +$lang = strtolower($codes[0]); +} else { +$lang .='_'.strtoupper($codes[$i]); +} +} +} +} +$this->languages[] = $lang; +} +return $this->languages; +} +public function getCharsets() +{ +if (null !== $this->charsets) { +return $this->charsets; +} +return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all()); +} +public function getEncodings() +{ +if (null !== $this->encodings) { +return $this->encodings; +} +return $this->encodings = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all()); +} +public function getAcceptableContentTypes() +{ +if (null !== $this->acceptableContentTypes) { +return $this->acceptableContentTypes; +} +return $this->acceptableContentTypes = array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all()); +} +public function isXmlHttpRequest() +{ +return'XMLHttpRequest'== $this->headers->get('X-Requested-With'); +} +protected function prepareRequestUri() +{ +$requestUri =''; +if ($this->headers->has('X_ORIGINAL_URL')) { +$requestUri = $this->headers->get('X_ORIGINAL_URL'); +$this->headers->remove('X_ORIGINAL_URL'); +$this->server->remove('HTTP_X_ORIGINAL_URL'); +$this->server->remove('UNENCODED_URL'); +$this->server->remove('IIS_WasUrlRewritten'); +} elseif ($this->headers->has('X_REWRITE_URL')) { +$requestUri = $this->headers->get('X_REWRITE_URL'); +$this->headers->remove('X_REWRITE_URL'); +} elseif ($this->server->get('IIS_WasUrlRewritten') =='1'&& $this->server->get('UNENCODED_URL') !='') { +$requestUri = $this->server->get('UNENCODED_URL'); +$this->server->remove('UNENCODED_URL'); +$this->server->remove('IIS_WasUrlRewritten'); +} elseif ($this->server->has('REQUEST_URI')) { +$requestUri = $this->server->get('REQUEST_URI'); +$schemeAndHttpHost = $this->getSchemeAndHttpHost(); +if (strpos($requestUri, $schemeAndHttpHost) === 0) { +$requestUri = substr($requestUri, strlen($schemeAndHttpHost)); +} +} elseif ($this->server->has('ORIG_PATH_INFO')) { +$requestUri = $this->server->get('ORIG_PATH_INFO'); +if (''!= $this->server->get('QUERY_STRING')) { +$requestUri .='?'.$this->server->get('QUERY_STRING'); +} +$this->server->remove('ORIG_PATH_INFO'); +} +$this->server->set('REQUEST_URI', $requestUri); +return $requestUri; +} +protected function prepareBaseUrl() +{ +$filename = basename($this->server->get('SCRIPT_FILENAME')); +if (basename($this->server->get('SCRIPT_NAME')) === $filename) { +$baseUrl = $this->server->get('SCRIPT_NAME'); +} elseif (basename($this->server->get('PHP_SELF')) === $filename) { +$baseUrl = $this->server->get('PHP_SELF'); +} elseif (basename($this->server->get('ORIG_SCRIPT_NAME')) === $filename) { +$baseUrl = $this->server->get('ORIG_SCRIPT_NAME'); } else { +$path = $this->server->get('PHP_SELF',''); +$file = $this->server->get('SCRIPT_FILENAME',''); +$segs = explode('/', trim($file,'/')); +$segs = array_reverse($segs); +$index = 0; +$last = count($segs); +$baseUrl =''; +do { +$seg = $segs[$index]; +$baseUrl ='/'.$seg.$baseUrl; +++$index; +} while ($last > $index && (false !== $pos = strpos($path, $baseUrl)) && 0 != $pos); +} +$requestUri = $this->getRequestUri(); +if ($requestUri !==''&& $requestUri[0] !=='/') { +$requestUri ='/'.$requestUri; +} +if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) { +return $prefix; +} +if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl),'/'.DIRECTORY_SEPARATOR).'/')) { +return rtrim($prefix,'/'.DIRECTORY_SEPARATOR); +} +$truncatedRequestUri = $requestUri; +if (false !== $pos = strpos($requestUri,'?')) { +$truncatedRequestUri = substr($requestUri, 0, $pos); +} +$basename = basename($baseUrl); +if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) { +return''; +} +if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && $pos !== 0) { +$baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl)); +} +return rtrim($baseUrl,'/'.DIRECTORY_SEPARATOR); +} +protected function prepareBasePath() +{ +$filename = basename($this->server->get('SCRIPT_FILENAME')); +$baseUrl = $this->getBaseUrl(); +if (empty($baseUrl)) { +return''; +} +if (basename($baseUrl) === $filename) { +$basePath = dirname($baseUrl); +} else { +$basePath = $baseUrl; +} +if ('\\'=== DIRECTORY_SEPARATOR) { +$basePath = str_replace('\\','/', $basePath); +} +return rtrim($basePath,'/'); +} +protected function preparePathInfo() +{ +$baseUrl = $this->getBaseUrl(); +if (null === ($requestUri = $this->getRequestUri())) { +return'/'; +} +if (false !== $pos = strpos($requestUri,'?')) { +$requestUri = substr($requestUri, 0, $pos); +} +if ($requestUri !==''&& $requestUri[0] !=='/') { +$requestUri ='/'.$requestUri; +} +$pathInfo = substr($requestUri, strlen($baseUrl)); +if (null !== $baseUrl && (false === $pathInfo ||''=== $pathInfo)) { +return'/'; +} elseif (null === $baseUrl) { +return $requestUri; +} +return (string) $pathInfo; +} +protected static function initializeFormats() +{ +static::$formats = array('html'=> array('text/html','application/xhtml+xml'),'txt'=> array('text/plain'),'js'=> array('application/javascript','application/x-javascript','text/javascript'),'css'=> array('text/css'),'json'=> array('application/json','application/x-json'),'xml'=> array('text/xml','application/xml','application/x-xml'),'rdf'=> array('application/rdf+xml'),'atom'=> array('application/atom+xml'),'rss'=> array('application/rss+xml'),'form'=> array('application/x-www-form-urlencoded'), +); +} +private function setPhpDefaultLocale($locale) +{ +try { +if (class_exists('Locale', false)) { +\Locale::setDefault($locale); +} +} catch (\Exception $e) { +} +} +private function getUrlencodedPrefix($string, $prefix) +{ +if (0 !== strpos(rawurldecode($string), $prefix)) { +return false; +} +$len = strlen($prefix); +if (preg_match(sprintf('#^(%%[[:xdigit:]]{2}|.){%d}#', $len), $string, $match)) { +return $match[0]; +} +return false; +} +private static function createRequestFromFactory(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) +{ +if (self::$requestFactory) { +$request = call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content); +if (!$request instanceof self) { +throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.'); +} +return $request; +} +return new static($query, $request, $attributes, $cookies, $files, $server, $content); +} +private function isFromTrustedProxy() +{ +return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies); +} +private function getTrustedValues($type, $ip = null) +{ +$clientValues = array(); +$forwardedValues = array(); +if (self::$trustedHeaders[$type] && $this->headers->has(self::$trustedHeaders[$type])) { +foreach (explode(',', $this->headers->get(self::$trustedHeaders[$type])) as $v) { +$clientValues[] = (self::HEADER_CLIENT_PORT === $type ?'0.0.0.0:':'').trim($v); +} +} +if (self::$trustedHeaders[self::HEADER_FORWARDED] && $this->headers->has(self::$trustedHeaders[self::HEADER_FORWARDED])) { +$forwardedValues = $this->headers->get(self::$trustedHeaders[self::HEADER_FORWARDED]); +$forwardedValues = preg_match_all(sprintf('{(?:%s)=(?:"?\[?)([a-zA-Z0-9\.:_\-/]*+)}', self::$forwardedParams[$type]), $forwardedValues, $matches) ? $matches[1] : array(); +} +if (null !== $ip) { +$clientValues = $this->normalizeAndFilterClientIps($clientValues, $ip); +$forwardedValues = $this->normalizeAndFilterClientIps($forwardedValues, $ip); +} +if ($forwardedValues === $clientValues || !$clientValues) { +return $forwardedValues; +} +if (!$forwardedValues) { +return $clientValues; +} +if (!$this->isForwardedValid) { +return null !== $ip ? array('0.0.0.0', $ip) : array(); +} +$this->isForwardedValid = false; +throw new ConflictingHeadersException(sprintf('The request has both a trusted "%s" header and a trusted "%s" header, conflicting with each other. You should either configure your proxy to remove one of them, or configure your project to distrust the offending one.', self::$trustedHeaders[self::HEADER_FORWARDED], self::$trustedHeaders[$type])); +} +private function normalizeAndFilterClientIps(array $clientIps, $ip) +{ +if (!$clientIps) { +return array(); +} +$clientIps[] = $ip; $firstTrustedIp = null; +foreach ($clientIps as $key => $clientIp) { +if (preg_match('{((?:\d+\.){3}\d+)\:\d+}', $clientIp, $match)) { +$clientIps[$key] = $clientIp = $match[1]; +} +if (!filter_var($clientIp, FILTER_VALIDATE_IP)) { +unset($clientIps[$key]); +continue; +} +if (IpUtils::checkIp($clientIp, self::$trustedProxies)) { +unset($clientIps[$key]); +if (null === $firstTrustedIp) { +$firstTrustedIp = $clientIp; +} +} +} +return $clientIps ? array_reverse($clientIps) : array($firstTrustedIp); +} +} +} diff --git a/Resources/test/Fixtures/App/app/config/parameters.yml b/Resources/test/Fixtures/App/app/config/parameters.yml new file mode 100644 index 000000000..f0e6be25e --- /dev/null +++ b/Resources/test/Fixtures/App/app/config/parameters.yml @@ -0,0 +1,13 @@ +parameters: + database_host: localhost +# database_host: 127.0.0.1 + database_port: 5435 +# database_port: 5454 + database_name: postgres + database_user: postgres + database_password: postgres + locale: fr + secret: ThisTokenIsNotSoSecretChangeIt + debug_toolbar: true + debug_redirects: false + use_assetic_controller: true diff --git a/Resources/test/Fixtures/App/app/console b/Resources/test/Fixtures/App/app/console index 07f73fd68..f6fd8e5ef 100644 --- a/Resources/test/Fixtures/App/app/console +++ b/Resources/test/Fixtures/App/app/console @@ -1,19 +1,19 @@ #!/usr/bin/env php getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev'); $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod'; diff --git a/apigen.neon b/apigen.neon index 42552e9f5..6fd31b419 100644 --- a/apigen.neon +++ b/apigen.neon @@ -6,5 +6,6 @@ source: exclude: - vendor/* - Test* + - Resources/test title: Chill Report Bundle diff --git a/composer.json b/composer.json index 03d88aa85..4edf8ab42 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,9 @@ "autoload": { "psr-4": { "Chill\\ReportBundle\\": "" } }, + "autoload-dev": { + "classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ] + }, "authors" : [ { "name": "Champs-Libres", @@ -50,7 +53,7 @@ ] }, "extra": { - "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations", + "app-migrations-dir": "Resources/test/Fixtures/App/app/DoctrineMigrations", "symfony-app-dir": "Tests/Fixtures/App/app" }, "minimum-stability": "dev", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a2fcbb39e..5e67beade 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ - @@ -20,7 +20,7 @@ - + From dab43fef6bf6061522d0a5e6efe3fe5f716c42e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 4 Jul 2017 21:53:47 +0200 Subject: [PATCH 158/210] remove search for surname The surname does not appears since the number of result is limited to 5 eleents --- Tests/Search/ReportSearchTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/Search/ReportSearchTest.php b/Tests/Search/ReportSearchTest.php index d4fc0e757..ce0bd1053 100644 --- a/Tests/Search/ReportSearchTest.php +++ b/Tests/Search/ReportSearchTest.php @@ -39,7 +39,6 @@ class ReportSearchTest extends WebTestCase )); $this->assertTrue($client->getResponse()->isSuccessful()); - $this->assertRegExp('/Charline/', $crawler->text()); $this->assertRegExp('/Situation de logement/i', $crawler->text()); } From 5aff866ed8ad0a0a965b147f08abac89139ee6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 19 Aug 2017 21:48:36 +0200 Subject: [PATCH 159/210] adapt layout to new rules --- Resources/views/Report/edit.html.twig | 12 ++++++++---- Resources/views/Report/list.html.twig | 10 ++++------ Resources/views/Report/new.html.twig | 11 ++++++++--- .../views/Report/select_report_type.html.twig | 15 +++++++++++---- Resources/views/Report/view.html.twig | 14 +++++++++++--- 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index 18009675a..47a7e4215 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -29,10 +29,14 @@ {{ form_row(edit_form.cFData) }} {{ form_widget(edit_form) }} -
    - - -
    + {{ form_end(edit_form) }} {% endblock %} diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index 8849f1832..d9d603e10 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -25,9 +25,8 @@

    {{ 'Report list'|trans }}

    {% if reports|length == 0 %} -

    +

    {{ "No report registered for this person."|trans }} - {{ 'Create a new report'|trans }}

    {% else %} @@ -36,7 +35,7 @@ - + @@ -49,12 +48,12 @@ @@ -73,7 +72,6 @@
    • - {{ 'Create a new report'|trans }}
    • diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index 744dca41c..8589601ae 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -27,9 +27,14 @@ {{ form_row(form.date) }} {{ form_row(form.scope) }} {{ form_row(form.cFData) }} -
      - -
      + {{ form_end(form) }} {% endblock %} diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index 52432883b..3297d5ef7 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -24,10 +24,17 @@ {{ form_start(form) }} {{ form_widget(form.cFGroup) }} - + + {{ form_end(form) }} {% endblock %} diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 3a6fde97f..286313366 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -43,7 +43,15 @@
      {{ chill_custom_fields_group_widget(entity.cFData, entity.cFGroup) }}
      - {% if is_granted('CHILL_REPORT_UPDATE', entity) %} - {{ 'Update the report' | trans }} - {% endif %} + + {% endblock %} From 0c49a21fb6690b7247a33f6c9f55afc8626cae91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 19 Aug 2017 23:07:45 +0200 Subject: [PATCH 160/210] layout of timeline --- Resources/translations/messages.fr.yml | 5 ++--- .../Timeline/report_person_context.html.twig | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 3d4b97198..04cc0c178 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -5,7 +5,7 @@ 'Add report': 'Ajouter le rapport' 'Create a new report': 'Créer un nouveau rapport' 'Report view': "Détails d'un rapport" -'Update the report': 'Mettre à jour le rapport' +'Update the report': 'Modifier le rapport' 'Report list': 'Liste des rapports' Details: Détails Person: Personne @@ -30,7 +30,6 @@ No report registered for this person.: Aucun rapport pour cette personne. 'Unable to find this report.': Rapport introuvable. 'This is not the report of the person.': "La personne et le rapport sélectionnés ne sont pas associés" -'You are going to leave a page with unsubmitted data. Are you sure you want to leave ?': "Vous allez quitter la page alors que des données n'ont pas été enregistrées. Êtes vous sûr de vouloir partir ?" #search 'You may not set a date argument and a date in default': Vous avez introduit deux dates, l'une avec l'argument date et l'autre en zone de recherche par défaut. Merci d'indiquer l'un ou l'autre @@ -39,7 +38,7 @@ No report registered for this person.: Aucun rapport pour cette personne. '%total% reports matching the search "%pattern%"': '{0} Aucun rapport ne correspond à la recherche "%pattern%" | {1} Un rapport correspond à la recherche "%pattern%" | ]1,Inf]%total% rapports correspondent à la recherche "%pattern%"' #timeline -'%user% has filled a %report_label% report on %date%': %user% a ajouté un rapport '%report_label%' le %date% +'%user% has filled a %report_label% report': %user% a ajouté un rapport '%report_label%' #roles CHILL_REPORT_UPDATE: Modifier les rapports diff --git a/Resources/views/Timeline/report_person_context.html.twig b/Resources/views/Timeline/report_person_context.html.twig index c7b4e5b3f..48925ebdc 100644 --- a/Resources/views/Timeline/report_person_context.html.twig +++ b/Resources/views/Timeline/report_person_context.html.twig @@ -1,13 +1,12 @@

      {{ report.date|localizeddate('long', 'none') }} / {{ 'Report'|trans }}

      - {{ '%user% has filled a %report_label% report on %date%'|trans( + {{ '%user% has filled a %report_label% report'|trans( { '%user%' : user, '%report_label%': report.CFGroup.name|localize_translatable_string, '%date%' : report.date|localizeddate('long', 'none') } - ) }} {{ 'View the report'|trans }} + ) }}
      {% if custom_fields_in_summary|length > 0 %}
      @@ -23,4 +22,19 @@
      {% endif %} + +
      From 986d10724e4877605b8b856c8a2edbc6560db338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 29 Aug 2017 17:42:38 +0200 Subject: [PATCH 161/210] fix test with new labels / classes --- Tests/Controller/ReportControllerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index 5ca7e9847..d7bf25f06 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -378,12 +378,12 @@ class ReportControllerTest extends WebTestCase $this->assertTrue($client->getResponse()->isSuccessful()); - $linkSee = $crawler->selectLink('Voir le rapport')->links(); + $linkSee = $crawler->filter('.bt-view')->links(); $this->assertGreaterThan(0, count($linkSee)); $this->assertRegExp(sprintf('|/fr/person/%s/report/[0-9]*/view$|', static::$person->getId(), $reportId), $linkSee[0]->getUri()); - $linkUpdate = $crawler->selectLink('Mettre à jour')->links(); + $linkUpdate = $crawler->filter('.bt-update')->links(); $this->assertGreaterThan(0, count($linkUpdate)); $this->assertRegExp(sprintf('|/fr/person/%s/report/[0-9]*/edit$|', static::$person->getId(), $reportId), $linkUpdate[0]->getUri()); From 37780125655fa2f971f8d16e7088c06e033e7c14 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 28 Mar 2018 17:40:09 +0200 Subject: [PATCH 162/210] update deprecated routing option: requirement -> methods --- Resources/config/routing.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 96a053bac..8b15f0077 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -10,12 +10,12 @@ report_new: path: /{_locale}/person/{person_id}/report/cfgroup/{cf_group_id}/new defaults: { _controller: "ChillReportBundle:Report:new" } -report_create: +report_create: path: /{_locale}/person/{person_id}/report/cfgroup/{cf_group_id}/create defaults: { _controller: "ChillReportBundle:Report:create" } - requirements: { _method: post } + methods: [POST] -report_list: +report_list: path: /{_locale}/person/{person_id}/report/list defaults: { _controller: "ChillReportBundle:Report:list" } options: @@ -34,7 +34,7 @@ report_edit: report_update: path: /{_locale}/person/{person_id}/report/{report_id}/update defaults: { _controller: "ChillReportBundle:Report:update" } - requirements: { _method: post|put } + methods: [POST, PUT] report_export_list: path: /{_locale}/export/report/cfgroup/{cf_group_id} @@ -49,4 +49,3 @@ report_export_select_type: export: order: 100 label: Export reports - \ No newline at end of file From 7637954a8dd1367d01fbf98f9e46f462db5020a0 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 4 Apr 2018 18:39:02 +0200 Subject: [PATCH 163/210] fix deprecations: use fqcn for customfieldtype --- Form/ReportType.php | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index aa56daa80..15b0fdf10 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -1,20 +1,20 @@ - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ @@ -29,37 +29,38 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\Common\Persistence\ObjectManager; +use Chill\CustomFieldsBundle\Form\Type\CustomFieldType; class ReportType extends AbstractType -{ +{ use AppendScopeChoiceTypeTrait; - + /** * * @var AuthorizationHelper */ protected $authorizationHelper; - + /** * * @var TranslatableStringHelper */ protected $translatableStringHelper; - + /** * * @var \Doctrine\Common\Persistence\ObjectManager */ protected $om; - + /** * * @var \Chill\MainBundle\Entity\User */ protected $user; - + public function __construct(AuthorizationHelper $helper, - TokenStorageInterface $tokenStorage, + TokenStorageInterface $tokenStorage, TranslatableStringHelper $translatableStringHelper, ObjectManager $om) { @@ -68,7 +69,7 @@ class ReportType extends AbstractType $this->translatableStringHelper = $translatableStringHelper; $this->om = $om; } - + /** * @param FormBuilderInterface $builder * @param array $options @@ -77,24 +78,24 @@ class ReportType extends AbstractType { $builder ->add('user') - ->add('date', 'date', + ->add('date', 'date', array('required' => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) - ->add('cFData', 'custom_field', - array('attr' => array('class' => 'cf-fields'), + ->add('cFData', CustomFieldType::class, + array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup'])) ; - - $this->appendScopeChoices($builder, $options['role'], $options['center'], - $this->user, $this->authorizationHelper, + + $this->appendScopeChoices($builder, $options['role'], $options['center'], + $this->user, $this->authorizationHelper, $this->translatableStringHelper, $this->om); } - + /** - * @param OptionsResolverInterface $resolver + * @param OptionsResolver $resolver */ public function configureOptions(OptionsResolver $resolver) - { + { $resolver->setDefaults(array( 'data_class' => 'Chill\ReportBundle\Entity\Report' )); @@ -106,7 +107,7 @@ class ReportType extends AbstractType $resolver->setAllowedTypes(array( 'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup', )); - + $this->appendScopeChoicesOptions($resolver); } From 6bf4f68f0deef881c6f50c29ce159b0fc07b8104 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 5 Apr 2018 07:34:52 +0200 Subject: [PATCH 164/210] fix deprecations: add 'choices_as_values=true' to ChoiceType elements --- Controller/ReportController.php | 101 +++++++++++++++++--------------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 87c3eaae9..b97025c8c 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -1,20 +1,20 @@ - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ @@ -23,10 +23,13 @@ namespace Chill\ReportBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Security\Core\Role\Role; + use Chill\PersonBundle\Entity\Person; use Chill\ReportBundle\Entity\Report; use Chill\ReportBundle\Form\ReportType; -use Symfony\Component\Security\Core\Role\Role; + /** * Report controller. @@ -46,26 +49,26 @@ class ReportController extends Controller $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - + $reachableScopes = $this->get('chill.main.security.authorization.helper') ->getReachableScopes($this->getUser(), new Role('CHILL_REPORT_SEE'), $person->getCenter()); - + $total = $em ->createQuery("SELECT COUNT(r.id) FROM ChillReportBundle:Report r " . "WHERE r.person = :person AND r.scope IN (:scopes) ") ->setParameter('person', $person) ->setParameter('scopes', $reachableScopes) ->getSingleScalarResult(); - + // get the PaginatorFactory $paginator = $this->get('chill_main.paginator_factory')->create($total); - - $reports = $em->createQuery('SELECT r + + $reports = $em->createQuery('SELECT r FROM ChillReportBundle:Report r - WHERE r.person = :person AND r.scope IN (:scopes) + WHERE r.person = :person AND r.scope IN (:scopes) ORDER BY r.date DESC') ->setParameter('person', $person) ->setParameter('scopes', $reachableScopes) @@ -73,7 +76,7 @@ class ReportController extends Controller ->setMaxResults($paginator->getItemsPerPage()) ->getResult() ; - + return $this->render('ChillReportBundle:Report:list.html.twig', array( 'reports' => $reports, 'person' => $person, @@ -91,20 +94,20 @@ class ReportController extends Controller public function selectReportTypeAction($person_id, Request $request) { $em = $this->getDoctrine()->getManager(); - + $person = $em->getRepository('ChillPersonBundle:Person') ->find($person_id); - + if ($person === NULL) { throw $this->createNotFoundException('Person not found!'); } - + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person, 'access denied for person view'); // check access on report creation for a dummy report - $this->denyAccessUnlessGranted('CHILL_REPORT_CREATE', + $this->denyAccessUnlessGranted('CHILL_REPORT_CREATE', (new Report())->setPerson($person), 'access denied for report creation'); - - + + $cFGroupId = $request->query->get('cFGroup'); if($cFGroupId) { @@ -118,7 +121,7 @@ class ReportController extends Controller if(count($cFGroups) === 1 ){ return $this->redirect( - $this->generateUrl('report_new', + $this->generateUrl('report_new', array('person_id' => $person_id, 'cf_group_id' => $cFGroups[0]->getId()))); } @@ -133,8 +136,9 @@ class ReportController extends Controller 'method' => 'GET', 'csrf_protection' => false )) - ->add('cFGroup', 'choice', array( - 'choices' => $cFGroupsChoice + ->add('cFGroup', ChoiceType::class, array( + 'choices' => $cFGroupsChoice, + 'choices_as_values' => true )) ->getForm(); @@ -147,7 +151,7 @@ class ReportController extends Controller } /** - * Display a form for selecting which type of report to export + * Display a form for selecting which type of report to export * (a csv file with all the report of this type) * * @param Request $request The request @@ -159,7 +163,7 @@ class ReportController extends Controller if($cFGroupId) { return $this->redirect( - $this->generateUrl('report_export_list', + $this->generateUrl('report_export_list', array('cf_group_id' => $cFGroupId))); } @@ -185,8 +189,9 @@ class ReportController extends Controller 'method' => 'GET', 'csrf_protection' => false )) - ->add('cFGroup', 'choice', array( - 'choices' => $cFGroupsChoice + ->add('cFGroup', ChoiceType::class, array( + 'choices' => $cFGroupsChoice, + 'choices_as_values' => true )) ->getForm(); @@ -201,7 +206,7 @@ class ReportController extends Controller * * @param integer $cf_group_id The id of the report type to export * @param Request $request The request - * @return A csv file with all the reports of the selected type + * @return A csv file with all the reports of the selected type */ public function exportAction($cf_group_id, Request $request) { @@ -233,20 +238,20 @@ class ReportController extends Controller { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $cFGroup = $em ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') ->find($cf_group_id); - + if ($person === NULL) { throw $this->createNotFoundException("Person not found"); } - + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); // check access on report creation for a dummy report - $this->denyAccessUnlessGranted('CHILL_REPORT_CREATE', + $this->denyAccessUnlessGranted('CHILL_REPORT_CREATE', (new Report())->setPerson($person), 'access denied for report creation'); - + if ($cFGroup === NULL){ throw $this->createNotFoundException("custom fields group not found"); } @@ -281,14 +286,14 @@ class ReportController extends Controller $entity = new Report(); $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') ->find($cf_group_id); - + $person = $em->getRepository('ChillPersonBundle:Person') ->find($person_id); - + if($person === NULL || $cFGroup === NULL) { throw $this->createNotFoundException(); } - + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); $form = $this->createCreateForm($entity, $person, $cFGroup); @@ -297,20 +302,20 @@ class ReportController extends Controller if ($form->isValid()) { $entity->setCFGroup($cFGroup); $entity->setPerson($person); - + $this->denyAccessUnlessGranted('CHILL_REPORT_CREATE', $entity); - + $em->persist($entity); $em->flush(); $this->get('session') ->getFlashBag() - ->add('success', + ->add('success', $this->get('translator') ->trans('Success : report created!') ); - return $this->redirect($this->generateUrl('report_view', + return $this->redirect($this->generateUrl('report_view', array('person_id' => $person_id,'report_id' => $entity->getId()))); } @@ -340,8 +345,8 @@ class ReportController extends Controller private function createCreateForm(Report $entity, Person $person, $cFGroup) { $form = $this->createForm('chill_reportbundle_report', $entity, array( - 'action' => $this->generateUrl('report_create', - array('person_id' => $person->getId(), + 'action' => $this->generateUrl('report_create', + array('person_id' => $person->getId(), 'cf_group_id' => $cFGroup->getId())), 'method' => 'POST', 'cFGroup' => $cFGroup, @@ -371,7 +376,7 @@ class ReportController extends Controller throw $this->createNotFoundException( $this->get('translator')->trans('Unable to find this report.')); } - + $this->denyAccessUnlessGranted('CHILL_REPORT_SEE', $entity); return $this->render('ChillReportBundle:Report:view.html.twig', array( @@ -402,7 +407,7 @@ class ReportController extends Controller throw new \RuntimeException( $this->get('translator')->trans('This is not the report of the person.'), 1); } - + $this->denyAccessUnlessGranted('CHILL_REPORT_UPDATE', $report); $person = $report->getPerson(); @@ -425,8 +430,8 @@ class ReportController extends Controller private function createEditForm(Report $entity) { $form = $this->createForm('chill_reportbundle_report', $entity, array( - 'action' => $this->generateUrl('report_update', - array('person_id' => $entity->getPerson()->getId(), + 'action' => $this->generateUrl('report_update', + array('person_id' => $entity->getPerson()->getId(), 'report_id' => $entity->getId())), 'method' => 'PUT', 'cFGroup' => $entity->getCFGroup(), @@ -454,7 +459,7 @@ class ReportController extends Controller throw $this->createNotFoundException( $this->get('translator')->trans('Unable to find this report.')); } - + $this->denyAccessUnlessGranted('CHILL_REPORT_UPDATE', $report); $editForm = $this->createEditForm($report); @@ -465,12 +470,12 @@ class ReportController extends Controller $this->get('session') ->getFlashBag() - ->add('success', + ->add('success', $this->get('translator') ->trans('Success : report updated!') ); - return $this->redirect($this->generateUrl('report_view', + return $this->redirect($this->generateUrl('report_view', array('person_id' => $report->getPerson()->getId(), 'report_id' => $report_id))); } From 4519a1c92c2b14a6c6221445e393ace8ff9ebc70 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 5 Apr 2018 08:07:15 +0200 Subject: [PATCH 165/210] fix deprecations: use fqcn for FormType --- Controller/ReportController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index b97025c8c..5dd97c998 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -25,6 +25,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Security\Core\Role\Role; +use Symfony\Component\Form\Extension\Core\Type\FormType; use Chill\PersonBundle\Entity\Person; use Chill\ReportBundle\Entity\Report; @@ -132,7 +133,7 @@ class ReportController extends Controller } $form = $this->get('form.factory') - ->createNamedBuilder(null, 'form', null, array( + ->createNamedBuilder(null, FormType::class, null, array( 'method' => 'GET', 'csrf_protection' => false )) From 1b4bb4f7bcddc30e8179cec222c0660ffe94e07d Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 5 Apr 2018 08:11:19 +0200 Subject: [PATCH 166/210] fix deprecations: flip content of choice type --- Controller/ReportController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 5dd97c998..5459be72f 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -138,7 +138,7 @@ class ReportController extends Controller 'csrf_protection' => false )) ->add('cFGroup', ChoiceType::class, array( - 'choices' => $cFGroupsChoice, + 'choices' => array_combine(array_values($cFGroupsChoice),array_keys($cFGroupsChoice)), 'choices_as_values' => true )) ->getForm(); From eeff93c88a7af48f5b955c72a715946af0759fb1 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 5 Apr 2018 09:54:28 +0200 Subject: [PATCH 167/210] fix deprecations: implement abstract function for reportVoter --- Security/Authorization/ReportVoter.php | 44 +++++++++++++++----------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/Security/Authorization/ReportVoter.php b/Security/Authorization/ReportVoter.php index 6ffb9d153..5227cbc9c 100644 --- a/Security/Authorization/ReportVoter.php +++ b/Security/Authorization/ReportVoter.php @@ -19,12 +19,17 @@ namespace Chill\ReportBundle\Security\Authorization; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; +use Chill\ReportBundle\Entity\Report; +use Chill\MainBundle\Entity\User; + /** - * + * * * @author Julien Fastré */ @@ -33,38 +38,41 @@ class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte const CREATE = 'CHILL_REPORT_CREATE'; const SEE = 'CHILL_REPORT_SEE'; const UPDATE = 'CHILL_REPORT_UPDATE'; - + /** * * @var AuthorizationHelper */ protected $helper; - + + public function __construct(AuthorizationHelper $helper) { $this->helper = $helper; } - - protected function getSupportedAttributes() - { - return array(self::CREATE, self::SEE, self::UPDATE); - } - protected function getSupportedClasses() - { - return array('Chill\ReportBundle\Entity\Report'); - } - protected function isGranted($attribute, $report, $user = null) + protected function supports($attribute, $subject) { - if (! $user instanceof \Chill\MainBundle\Entity\User){ - + if ($subject instanceof Report) { + return \in_array($attribute, [ + self::CREATE, self::UPDATE, self::SEE + ]); + } else { return false; } - - return $this->helper->userHasAccess($user, $report, $attribute); } + + protected function voteOnAttribute($attribute, $subject, TokenInterface $token) + { + if (!$token->getUser() instanceof User) { + return false; + } + return $this->helper->userHasAccess($token->getUser(), $subject, $attribute); + } + + public function getRoles() { return $this->getSupportedAttributes(); @@ -74,7 +82,7 @@ class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte { return array(); } - + public function getRolesWithHierarchy() { return [ 'Report' => $this->getRoles() ]; From bc6716a5fd5429abe53a6ca7d69096ead05f5653 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 5 Apr 2018 10:35:15 +0200 Subject: [PATCH 168/210] fix deprecations: remove array in setAllowedTypes --- Form/ReportType.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index 15b0fdf10..aeebacc06 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -104,9 +104,7 @@ class ReportType extends AbstractType 'cFGroup', )); - $resolver->setAllowedTypes(array( - 'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup', - )); + $resolver->setAllowedTypes('cFGroup', 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'); $this->appendScopeChoicesOptions($resolver); } From d4d14d1a068bc3403a9721e649dd2724856ad7d7 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 5 Apr 2018 12:36:58 +0200 Subject: [PATCH 169/210] fix deprecations: use fqcn --- Controller/ReportController.php | 6 +++--- Form/ReportType.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 5459be72f..ea3349c7e 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -186,7 +186,7 @@ class ReportController extends Controller } $form = $this->get('form.factory') - ->createNamedBuilder(null, 'form', null, array( + ->createNamedBuilder(null, FormType::class, null, array( 'method' => 'GET', 'csrf_protection' => false )) @@ -345,7 +345,7 @@ class ReportController extends Controller */ private function createCreateForm(Report $entity, Person $person, $cFGroup) { - $form = $this->createForm('chill_reportbundle_report', $entity, array( + $form = $this->createForm(ReportType::class, $entity, array( 'action' => $this->generateUrl('report_create', array('person_id' => $person->getId(), 'cf_group_id' => $cFGroup->getId())), @@ -430,7 +430,7 @@ class ReportController extends Controller */ private function createEditForm(Report $entity) { - $form = $this->createForm('chill_reportbundle_report', $entity, array( + $form = $this->createForm(ReportType::class, $entity, array( 'action' => $this->generateUrl('report_update', array('person_id' => $entity->getPerson()->getId(), 'report_id' => $entity->getId())), diff --git a/Form/ReportType.php b/Form/ReportType.php index aeebacc06..a61ab6a7a 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -27,6 +27,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Chill\MainBundle\Form\Type\AppendScopeChoiceTypeTrait; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Form\Extension\Core\Type\DateType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\Common\Persistence\ObjectManager; use Chill\CustomFieldsBundle\Form\Type\CustomFieldType; @@ -78,7 +79,7 @@ class ReportType extends AbstractType { $builder ->add('user') - ->add('date', 'date', + ->add('date', DateType::class, array('required' => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) ->add('cFData', CustomFieldType::class, array('attr' => array('class' => 'cf-fields'), From 6ee9dd56c0bbbdfda6fc84dd9eecd4b1a945b616 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 5 Apr 2018 14:15:50 +0200 Subject: [PATCH 170/210] fix error: flip content of choices field --- Controller/ReportController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index ea3349c7e..6b160259b 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -191,7 +191,7 @@ class ReportController extends Controller 'csrf_protection' => false )) ->add('cFGroup', ChoiceType::class, array( - 'choices' => $cFGroupsChoice, + 'choices' => array_combine(array_values($cFGroupsChoice),array_keys($cFGroupsChoice)), 'choices_as_values' => true )) ->getForm(); From 3260e9e7bd9c2f4d8e845b14e868105765ba06ea Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 9 Apr 2018 10:55:03 +0200 Subject: [PATCH 171/210] fix deprecations: getName -> getBlockPrefix in forms --- Form/ReportType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index a61ab6a7a..3a0a1d6f2 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -113,7 +113,7 @@ class ReportType extends AbstractType /** * @return string */ - public function getName() + public function getBlockPrefix() { return 'chill_reportbundle_report'; } From 1d10d89a9b72d3c6aa2d1d8a83c5ba5effe37fa2 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 9 Apr 2018 10:56:17 +0200 Subject: [PATCH 172/210] fix deprecation: use fqcn in a depedency injection --- DependencyInjection/ChillReportExtension.php | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index 2df5a38ae..1c3f9905a 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -8,6 +8,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Chill\MainBundle\DependencyInjection\MissingBundleException; +use Chill\CustomFieldsBundle\Form\Type\LinkedCustomFieldsType; /** * This is the class that loads and manages your bundle configuration @@ -30,7 +31,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac /** * Declare the entity Report, as a customizable entity (can add custom fields) - * + * * @param ContainerBuilder $container */ public function declareReportAsCustomizable(ContainerBuilder $container) @@ -41,15 +42,15 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac } $container->prependExtensionConfig('chill_custom_fields', - array('customizables_entities' => + array('customizables_entities' => array( array( - 'class' => 'Chill\ReportBundle\Entity\Report', + 'class' => 'Chill\ReportBundle\Entity\Report', 'name' => 'ReportEntity', 'options' => array( 'summary_fields' => array( - 'form_type' => 'custom_fields_group_linked_custom_fields', - 'form_options' => + 'form_type' => LinkedCustomFieldsType::class, + 'form_options' => [ 'multiple' => true, 'expanded' => false @@ -60,10 +61,10 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac ) ); } - + /** * declare routes from report bundle - * + * * @param ContainerBuilder $container */ private function declareRouting(ContainerBuilder $container) @@ -76,7 +77,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac ) )); } - + protected function prependRoleHierarchy(ContainerBuilder $container) { $container->prependExtensionConfig('security', array( @@ -89,7 +90,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac /** * {@inheritdoc} - * + * * @param ContainerBuilder $container */ public function prepend(ContainerBuilder $container) @@ -98,5 +99,5 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac $this->declareRouting($container); $this->prependRoleHierarchy($container); } - + } From 780d7514558399b69f66027181e5708b4f3ee7a0 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 9 Apr 2018 12:11:27 +0200 Subject: [PATCH 173/210] fix deprecations: use security.token_storage instead of security.context --- Controller/ReportController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 6b160259b..6d9af377e 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -258,7 +258,7 @@ class ReportController extends Controller } $entity = new Report(); - $entity->setUser($this->get('security.context')->getToken()->getUser()); + $entity->setUser($this->get('security.token_storage')->getToken()->getUser()); $entity->setDate(new \DateTime('now')); $entity->setCFGroup($cFGroup); From 04b8682fed77ee9f843445eb5ed005674fbe7721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 13 Apr 2018 14:13:43 +0200 Subject: [PATCH 174/210] set deps to upgrade-sf3 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 4edf8ab42..5f8613ea6 100644 --- a/composer.json +++ b/composer.json @@ -28,9 +28,9 @@ "doctrine/orm": "~2.4", "doctrine/common": "~2.4", "doctrine/doctrine-bundle": "~1.2", - "chill-project/main": "dev-master", - "chill-project/custom-fields": "dev-master@dev", - "chill-project/person": "dev-master", + "chill-project/main": "dev-upgrade-sf3@dev", + "chill-project/custom-fields": "dev-upgrade-sf3@dev", + "chill-project/person": "dev-upgrade-sf3@dev", "champs-libres/composer-bundle-migration": "~1.0", "doctrine/doctrine-migrations-bundle": "~1.1", "doctrine/migrations": "~1.0" From d78eb7277758a130262ef45c398948fe32e7e420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 24 Apr 2018 14:49:52 +0200 Subject: [PATCH 175/210] switch composer.json to syfmony3 --- .gitlab-ci.yml | 14 ++++---------- composer.json | 14 +------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b50126097..ea2639b41 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,21 +16,15 @@ stages: - build-doc - deploy-doc -test:php-7.1: +test:php-7.2: stage: test - image: chill/ci-image:php-7.1 + image: chill/ci-image:php-7.2 <<: *test_definition script: php vendor/bin/phpunit -test:php-7: - stage: test - image: chill/ci-image:php-7 - <<: *test_definition - script: php vendor/bin/phpunit - deploy-packagist: stage: deploy - image: chill/ci-image:php-7 + image: chill/ci-image:php-7.2 before_script: # test that PACKAGIST USERNAME and PACKAGIST_TOKEN variable are set - if [ -z ${PACKAGIST_USERNAME+x} ]; then echo "Please set PACKAGIST_USERNAME variable"; exit -1; fi @@ -43,7 +37,7 @@ deploy-packagist: api-doc-build: stage: build-doc environment: api-doc - image: chill/ci-image:php-7 + image: chill/ci-image:php-7.2 before_script: - mkdir api-doc script: apigen generate --destination api-doc/$CI_BUILD_REF_NAME/$CI_PROJECT_NAME diff --git a/composer.json b/composer.json index 5f8613ea6..c528d89e4 100644 --- a/composer.json +++ b/composer.json @@ -19,21 +19,9 @@ } ], "require": { - "twig/extensions": "~1.0", - "symfony/assetic-bundle": "~2.3", - "symfony/framework-bundle": "~2.7", - "symfony/yaml": "~2.7", - "symfony/symfony": "~2.7", - "doctrine/dbal": "~2.5", - "doctrine/orm": "~2.4", - "doctrine/common": "~2.4", - "doctrine/doctrine-bundle": "~1.2", "chill-project/main": "dev-upgrade-sf3@dev", "chill-project/custom-fields": "dev-upgrade-sf3@dev", - "chill-project/person": "dev-upgrade-sf3@dev", - "champs-libres/composer-bundle-migration": "~1.0", - "doctrine/doctrine-migrations-bundle": "~1.1", - "doctrine/migrations": "~1.0" + "chill-project/person": "dev-upgrade-sf3@dev" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "~2.2", From 835b36f281f9b097e6aafcce0360a20d569190e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 4 May 2018 22:52:05 +0200 Subject: [PATCH 176/210] re-enable fixtures with sf3 --- DependencyInjection/ChillReportExtension.php | 1 + Resources/config/services/fixtures.yml | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 Resources/config/services/fixtures.yml diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index 1c3f9905a..f6f8f7551 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -27,6 +27,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); + $loader->load('services/fixtures.yml'); } /** diff --git a/Resources/config/services/fixtures.yml b/Resources/config/services/fixtures.yml new file mode 100644 index 000000000..dfb34ddc4 --- /dev/null +++ b/Resources/config/services/fixtures.yml @@ -0,0 +1,4 @@ +services: + Chill\ReportBundle\DataFixtures\ORM\: + resource: ../../../DataFixtures/ORM + tags: [ 'doctrine.fixture.orm' ] \ No newline at end of file From 9c87db1519d9b7728eaa4d675800b74bf73dfcb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 16 May 2018 16:59:33 +0200 Subject: [PATCH 177/210] upgrade ReportVoter to sf3 --- Security/Authorization/ReportVoter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Security/Authorization/ReportVoter.php b/Security/Authorization/ReportVoter.php index 5227cbc9c..2950abd8d 100644 --- a/Security/Authorization/ReportVoter.php +++ b/Security/Authorization/ReportVoter.php @@ -75,7 +75,7 @@ class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte public function getRoles() { - return $this->getSupportedAttributes(); + return [self::CREATE, self::UPDATE, self::SEE]; } public function getRolesWithoutScope() From 84c22fcf59dff6720e20b8ca344379eeaa27e975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 13 Jun 2018 16:46:58 +0200 Subject: [PATCH 178/210] add list for exports --- DependencyInjection/ChillReportExtension.php | 1 + Export/Export/ReportList.php | 547 +++++++++++++++++++ Export/Export/ReportListProvider.php | 77 +++ Export/Filter/ReportDateFilter.php | 75 +++ Resources/config/services/export.yml | 13 + Resources/translations/messages.fr.yml | 10 +- Security/Authorization/ReportVoter.php | 10 +- 7 files changed, 728 insertions(+), 5 deletions(-) create mode 100644 Export/Export/ReportList.php create mode 100644 Export/Export/ReportListProvider.php create mode 100644 Export/Filter/ReportDateFilter.php create mode 100644 Resources/config/services/export.yml diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index f6f8f7551..56d8effc5 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -28,6 +28,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); $loader->load('services/fixtures.yml'); + $loader->load('services/export.yml'); } /** diff --git a/Export/Export/ReportList.php b/Export/Export/ReportList.php new file mode 100644 index 000000000..3da656aa0 --- /dev/null +++ b/Export/Export/ReportList.php @@ -0,0 +1,547 @@ + + */ +class ReportList implements ListInterface, ExportElementValidatedInterface +{ + /** + * + * @var CustomFieldsGroup + */ + protected $customfieldsGroup; + + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + /** + * + * @var TranslatorInterface + */ + protected $translator; + + /** + * + * @var CustomFieldProvider + */ + protected $customFieldProvider; + + protected $em; + + protected $fields = array( + 'person_id', 'person_firstName', 'person_lastName', 'person_birthdate', + 'person_placeOfBirth', 'person_gender', 'person_memo', 'person_email', 'person_phonenumber', + 'person_countryOfBirth', 'person_nationality', 'person_address_street_address_1', + 'person_address_street_address_2', 'person_address_valid_from', 'person_address_postcode_label', + 'person_address_postcode_code', 'person_address_country_name', 'person_address_country_code', + 'report_id', 'report_user', 'report_date', 'report_scope' + ); + + protected $slugs = []; + + function __construct( + CustomFieldsGroup $customfieldsGroup, + TranslatableStringHelper $translatableStringHelper, + TranslatorInterface $translator, + CustomFieldProvider $customFieldProvider, + EntityManagerInterface $em + ) { + $this->customfieldsGroup = $customfieldsGroup; + $this->translatableStringHelper = $translatableStringHelper; + $this->translator = $translator; + $this->customFieldProvider = $customFieldProvider; + $this->em = $em; + } + + + public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder) + { + $choices = array_combine($this->fields, $this->fields); + + foreach ($this->getCustomFields() as $cf) { + $choices + [$this->translatableStringHelper->localize($cf->getName())] + = + $cf->getSlug(); + } + + // Add a checkbox to select fields + $builder->add('fields', ChoiceType::class, array( + 'multiple' => true, + 'expanded' => true, + 'choices' => $choices, + 'label' => 'Fields to include in export', + 'choice_attr' => function($val, $key, $index) { + // add a 'data-display-target' for address fields + if (substr($val, 0, 8) === 'address_') { + return ['data-display-target' => 'address_date']; + } else { + return []; + } + }, + 'choice_label' => function($key, $label) { + switch (\substr($key, 0, 7)) { + case 'person_': + return $this->translator->trans(\substr($key, 7, \strlen($key) - 7)). + ' ('.$this->translator->trans('Person').')'; + case 'report_': + return $this->translator->trans(\ucfirst(\substr($key, 7, \strlen($key) - 7))). + ' ('.$this->translator->trans('Report').')'; + default: + return $label. + ' ('.$this->translator->trans("Report's question").')';; + } + }, + 'constraints' => [new Callback(array( + 'callback' => function($selected, ExecutionContextInterface $context) { + if (count($selected) === 0) { + $context->buildViolation('You must select at least one element') + ->atPath('fields') + ->addViolation(); + } + } + ))] + )); + + // add a date field for addresses + $builder->add('address_date', ChillDateType::class, array( + 'label' => "Address valid at this date", + 'data' => new \DateTime(), + 'required' => false, + 'block_name' => 'list_export_form_address_date' + )); + } + + public function validateForm($data, ExecutionContextInterface $context) + { + // get the field starting with address_ + $addressFields = array_filter(function($el) { + return substr($el, 0, 8) === 'address_'; + }, $this->fields); + + // check if there is one field starting with address in data + if (count(array_intersect($data['fields'], $addressFields)) > 0) { + // if a field address is checked, the date must not be empty + if (empty($data['address_date'])) { + $context + ->buildViolation("You must set this date if an address is checked") + ->atPath('address_date') + ->addViolation(); + } + } + } + + /** + * Get custom fields associated with person + * + * @return CustomField[] + */ + private function getCustomFields() + { + return \array_filter($this->customfieldsGroup + ->getCustomFields()->toArray(), function(CustomField $cf) { + return $cf->getType() !== 'title'; + }); + } + + public function getAllowedFormattersTypes() + { + return array(FormatterInterface::TYPE_LIST); + } + + public function getDescription() + { + return $this->translator->trans( + "Generate list of report '%type%'", + [ + '%type%' => $this->translatableStringHelper->localize($this->customfieldsGroup->getName()) + ] + ); + } + + /** + * {@inheritDoc} + * + * @param type $key + * @param array $values + * @param type $data + * @return type + */ + public function getLabels($key, array $values, $data) + { + switch ($key) { + case 'person_birthdate': + case 'report_date': + // for birthdate or report date, we have to transform the string into a date + // to format the date correctly. + return function($value) use ($key) { + if ($value === '_header') { + return $key === 'person_birthdate' ? 'birthdate' : 'report_date'; + } + + if (empty($value)) + { + return ""; + } + + if ($key === 'person_birthdate') { + $date = \DateTime::createFromFormat('Y-m-d', $value); + } else { + $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value); + } + // check that the creation could occurs. + if ($date === false) { + throw new \Exception(sprintf("The value %s could " + . "not be converted to %s", $value, \DateTime::class)); + } + + return $date->format('d-m-Y'); + }; + case 'report_scope': + $qb = $this->em->getRepository(Scope::class) + ->createQueryBuilder('s'); + $qb->addSelect('s.name') + ->addSelect('s.id') + ->where($qb->expr()->in('s.id', $values)) + ; + $rows = $qb->getQuery()->getResult(Query::HYDRATE_ARRAY); + + foreach($rows as $row) { + $scopes[$row['id']] = $this->translatableStringHelper + ->localize($row['name']); + } + + return function($value) use ($scopes) { + if ($value === '_header') { + return 'circle'; + } + + return $scopes[$value]; + }; + case 'report_user': + $qb = $this->em->getRepository(User::class) + ->createQueryBuilder('u'); + $qb->addSelect('u.username') + ->addSelect('u.id') + ->where($qb->expr()->in('u.id', $values)) + ; + $rows = $qb->getQuery()->getResult(Query::HYDRATE_ARRAY); + + foreach($rows as $row) { + $users[$row['id']] = $row['username']; + } + + return function($value) use ($users) { + if ($value === '_header') { + return 'user'; + } + + return $users[$value]; + }; + case 'person_gender' : + // for gender, we have to translate men/women statement + return function($value) { + if ($value === '_header') { return 'gender'; } + + return $this->translator->trans($value); + }; + case 'person_countryOfBirth': + case 'person_nationality': + $countryRepository = $this->em + ->getRepository('ChillMainBundle:Country'); + + // load all countries in a single query + $countryRepository->findBy(array('countryCode' => $values)); + + return function($value) use ($key, $countryRepository) { + if ($value === '_header') { return \strtolower($key); } + + if ($value === NULL) { + return $this->translator->trans('no data'); + } + + $country = $countryRepository->find($value); + + return $this->translatableStringHelper->localize( + $country->getName()); + }; + case 'person_address_country_name': + return function($value) use ($key) { + if ($value === '_header') { return \strtolower($key); } + + if ($value === NULL) { + return ''; + } + + return $this->translatableStringHelper->localize(json_decode($value, true)); + }; + default: + // for fields which are associated with person + if (in_array($key, $this->fields)) { + return function($value) use ($key) { + if ($value === '_header') { return \strtolower($key); } + + return $value; + + }; + } else { + return $this->getLabelForCustomField($key, $values, $data); + } + } + + } + + private function getLabelForCustomField($key, array $values, $data) + { + // for fields which are custom fields + /* @var $cf CustomField */ + $cf = $this->em + ->getRepository(CustomField::class) + ->findOneBy(array('slug' => $this->DQLToSlug($key))); + + $cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType()); + $defaultFunction = function($value) use ($cf) { + if ($value === '_header') { + return $this->translatableStringHelper->localize($cf->getName()); + } + + return $this->customFieldProvider + ->getCustomFieldByType($cf->getType()) + ->render(json_decode($value, true), $cf, 'csv'); + }; + + if ($cfType instanceof CustomFieldChoice and $cfType->isMultiple($cf)) { + return function($value) use ($cf, $cfType, $key) { + $slugChoice = $this->extractInfosFromSlug($key)['additionnalInfos']['choiceSlug']; + $decoded = \json_decode($value, true); + + if ($value === '_header') { + + $label = $cfType->getChoices($cf)[$slugChoice]; + + return $this->translatableStringHelper->localize($cf->getName()) + .' | '.$label; + } + + if ($slugChoice === '_other' and $cfType->isChecked($cf, $choiceSlug, $decoded)) { + return $cfType->extractOtherValue($cf, $decoded); + } else { + return $cfType->isChecked($cf, $slugChoice, $decoded); + } + }; + + } else { + return $defaultFunction; + } + } + + public function getQueryKeys($data) + { + $fields = array(); + + foreach ($data['fields'] as $key) { + if (in_array($key, $this->fields)) { + $fields[] = $key; + } + } + + // add the key from slugs and return + return \array_merge($fields, \array_keys($this->slugs)); + } + + /** + * clean a slug to be usable by DQL + * + * @param string $slugsanitize + * @param string $type the type of the customfield, if required (currently only for choices) + * @return string + */ + private function slugToDQL($slug, $type = "default", array $additionalInfos = []) + { + $uid = 'slug_'.\uniqid(); + + $this->slugs[$uid] = [ + 'slug' => $slug, + 'type' => $type, + 'additionnalInfos' => $additionalInfos + ]; + + return $uid; + } + + private function DQLToSlug($cleanedSlug) + { + return $this->slugs[$cleanedSlug]['slug']; + } + + /** + * + * @param type $cleanedSlug + * @return an array with keys = 'slug', 'type', 'additionnalInfo' + */ + private function extractInfosFromSlug($slug) + { + return $this->slugs[$slug]; + } + + public function getResult($query, $data) + { + return $query->getQuery()->getResult(Query::HYDRATE_SCALAR); + } + + public function getTitle() + { + return $this->translator->trans( + "List for report '%type%'", + [ + '%type%' => $this->translatableStringHelper->localize($this->customfieldsGroup->getName()) + ] + ); + } + + public function getType() + { + return 'report'; + } + + public function initiateQuery(array $requiredModifiers, array $acl, array $data = array()) + { + $centers = array_map(function($el) { return $el['center']; }, $acl); + + // throw an error if any fields are present + if (!\array_key_exists('fields', $data)) { + throw new \Doctrine\DBAL\Exception\InvalidArgumentException("any fields " + . "have been checked"); + } + + $qb = $this->em->createQueryBuilder(); + + foreach ($this->fields as $f) { + if (!\in_array($f, $data['fields'])) { + continue; + } + + switch ($f) { + case 'person_countryOfBirth': + case 'person_nationality': + $suffix = \substr($f, 7); + $qb->addSelect(sprintf('IDENTITY(person.%s) as %s', $suffix, $f)); + break; + case 'person_address_street_address_1': + case 'person_address_street_address_2': + case 'person_address_valid_from': + case 'person_address_postcode_label': + case 'person_address_postcode_code': + case 'person_address_country_name': + case 'person_address_country_code': + // remove 'person_' + $suffix = \substr($f, 7); + + $qb->addSelect(sprintf( + 'GET_PERSON_ADDRESS_%s(person.id, :address_date) AS %s', + // get the part after address_ + strtoupper(substr($suffix, 8)), + $f)); + $qb->setParameter('address_date', $data['address_date']); + break; + case 'report_scope': + $qb->addSelect(sprintf('IDENTITY(report.scope) AS %s', 'report_scope')); + break; + case 'report_user': + $qb->addSelect(sprintf('IDENTITY(report.user) AS %s', 'report_user')); + break; + default: + $prefix = \substr($f, 0, 7); + $suffix = \substr($f, 7); + + switch($prefix) { + case 'person_': + $qb->addSelect(sprintf('person.%s as %s', $suffix, $f)); + break; + case 'report_': + $qb->addSelect(sprintf('report.%s as %s', $suffix, $f)); + break; + default: + throw new \LogicException("this prefix $prefix should " + . "not be encountered. Full field: $f"); + } + } + + } + + foreach ($this->getCustomFields() as $cf) { + + $cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType()); + + if ($cfType instanceof CustomFieldChoice and $cfType->isMultiple($cf)) { + foreach($cfType->getChoices($cf) as $choiceSlug => $label) { + $slug = $this->slugToDQL($cf->getSlug(), 'choice', [ 'choiceSlug' => $choiceSlug ]); + $qb->addSelect( + sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s', + $slug, $slug)); + $qb->setParameter(sprintf('slug%s', $slug), $cf->getSlug()); + } + } else { + $slug = $this->slugToDQL($cf->getSlug()); + $qb->addSelect( + sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s', + $slug, $slug)); + $qb->setParameter(sprintf('slug%s', $slug), $cf->getSlug()); + } + } + + $qb + ->from(Report::class, 'report') + ->leftJoin('report.person', 'person') + ->join('person.center', 'center') + ->andWhere($qb->expr()->eq('report.cFGroup', ':cFGroup')) + ->setParameter('cFGroup', $this->customfieldsGroup) + ->andWhere('center IN (:authorized_centers)') + ->setParameter('authorized_centers', $centers); + ; + + + return $qb; + } + + public function requiredRole() + { + return new Role(ReportVoter::LISTS); + } + + public function supportsModifiers() + { + return [Declarations::PERSON_IMPLIED_IN, Declarations::PERSON_TYPE, 'report']; + } +} diff --git a/Export/Export/ReportListProvider.php b/Export/Export/ReportListProvider.php new file mode 100644 index 000000000..e7b8a2a79 --- /dev/null +++ b/Export/Export/ReportListProvider.php @@ -0,0 +1,77 @@ + + */ +class ReportListProvider implements ExportElementsProviderInterface +{ + /** + * + * @var EntityManagerInterface + */ + protected $em; + + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + /** + * + * @var CustomFieldProvider + */ + protected $customFieldProvider; + + /** + * + * @var TranslatorInterface + */ + protected $translator; + + function __construct( + EntityManagerInterface $em, + TranslatableStringHelper $translatableStringHelper, + TranslatorInterface $translator, + CustomFieldProvider $customFieldProvider + ) { + $this->em = $em; + $this->translatableStringHelper = $translatableStringHelper; + $this->translator = $translator; + $this->customFieldProvider = $customFieldProvider; + } + + + + public function getExportElements() + { + $groups = $this->em->getRepository(CustomFieldsGroup::class) + ->findBy([ 'entity' => Report::class ]) + ; + $reports = []; + + foreach ($groups as $group) { + $reports[$group->getId()] = new ReportList( + $group, + $this->translatableStringHelper, + $this->translator, + $this->customFieldProvider, + $this->em); + } + + return $reports; + } +} diff --git a/Export/Filter/ReportDateFilter.php b/Export/Filter/ReportDateFilter.php new file mode 100644 index 000000000..379d9ccda --- /dev/null +++ b/Export/Filter/ReportDateFilter.php @@ -0,0 +1,75 @@ + + */ +class ReportDateFilter implements FilterInterface +{ + + public function addRole() + { + return null; + } + + public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->between('report.date', ':report_date_filter_date_from', + ':report_date_filter_date_to'); + + if ($where instanceof Expr\Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('report_date_filter_date_from', $data['date_from']); + $qb->setParameter('report_date_filter_date_to', $data['date_to']); + } + + public function applyOn() + { + return 'report'; + } + + public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder) + { + $builder->add('date_from', ChillDateType::class, array( + 'label' => "Report is after this date", + 'data' => new \DateTime(), + )); + + $builder->add('date_to', ChillDateType::class, array( + 'label' => "Report is before this date", + 'data' => new \DateTime(), + )); + } + + public function describeAction($data, $format = 'string') + { + return array('Filtered by report\'s date: ' + . 'between %date_from% and %date_to%', array( + '%date_from%' => $data['date_from']->format('d-m-Y'), + '%date_to%' => $data['date_to']->format('d-m-Y') + )); + } + + public function getTitle() + { + return 'Filter by report\'s date'; + } +} diff --git a/Resources/config/services/export.yml b/Resources/config/services/export.yml new file mode 100644 index 000000000..4b9d7a7e7 --- /dev/null +++ b/Resources/config/services/export.yml @@ -0,0 +1,13 @@ +services: + Chill\ReportBundle\Export\Export\ReportListProvider: + arguments: + $em: '@Doctrine\ORM\EntityManagerInterface' + $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + $customFieldProvider: '@Chill\CustomFieldsBundle\Service\CustomFieldProvider' + tags: + - { name: chill.export_elements_provider, prefix: 'report' } + + Chill\ReportBundle\Export\Filter\ReportDateFilter: + tags: + - { name: chill.export_filter, alias: 'report_date' } diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 04cc0c178..6ea3a2600 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -43,4 +43,12 @@ No report registered for this person.: Aucun rapport pour cette personne. #roles CHILL_REPORT_UPDATE: Modifier les rapports CHILL_REPORT_SEE: Voir les rapports -CHILL_REPORT_CREATE: Créer des rapports \ No newline at end of file +CHILL_REPORT_CREATE: Créer des rapports + +#exports +"List for report '%type%'": Liste des rapports "%type%" +"Generate list of report '%type%'": Génère une liste des rapports "%type%" +"Report's question": Question du rapport +Filter by report's date: Filtrer par date de rapport +Report is after this date: Rapports après cette date +Report is before this date: Rapports avant cette date \ No newline at end of file diff --git a/Security/Authorization/ReportVoter.php b/Security/Authorization/ReportVoter.php index 2950abd8d..5741b567b 100644 --- a/Security/Authorization/ReportVoter.php +++ b/Security/Authorization/ReportVoter.php @@ -26,6 +26,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\ReportBundle\Entity\Report; use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Entity\Center; /** @@ -38,6 +39,7 @@ class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte const CREATE = 'CHILL_REPORT_CREATE'; const SEE = 'CHILL_REPORT_SEE'; const UPDATE = 'CHILL_REPORT_UPDATE'; + const LISTS = 'CHILL_REPORT_LISTS'; /** * @@ -58,8 +60,8 @@ class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte return \in_array($attribute, [ self::CREATE, self::UPDATE, self::SEE ]); - } else { - return false; + } elseif ($subject instanceof Center) { + return $attribute === self::LISTS; } } @@ -75,12 +77,12 @@ class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte public function getRoles() { - return [self::CREATE, self::UPDATE, self::SEE]; + return [self::CREATE, self::UPDATE, self::SEE, self::LISTS]; } public function getRolesWithoutScope() { - return array(); + return array(self::LISTS); } public function getRolesWithHierarchy() From 74bb2b3e517ccfed2b3f7772fea8017cc51fb33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 10 Sep 2018 14:21:20 +0200 Subject: [PATCH 179/210] upgrade to new search interface --- Search/ReportSearch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Search/ReportSearch.php b/Search/ReportSearch.php index e5a80716a..be4063802 100644 --- a/Search/ReportSearch.php +++ b/Search/ReportSearch.php @@ -78,7 +78,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface return false; } - public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array()) + public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array(), $format = 'html') { return $this->container->get('templating')->render('ChillReportBundle:Search:results.html.twig', array( 'reports' => $this->getReports($terms, $start, $limit), @@ -178,7 +178,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface return $whereElement; } - public function supports($domain) + public function supports($domain, $format = 'html') { return $domain === 'report'; } From 9e0359ac36e973590555937459c129e269ad603d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 10 Sep 2018 14:24:38 +0200 Subject: [PATCH 180/210] remove packagist from gitlab-ci --- .gitlab-ci.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea2639b41..126ed8194 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,6 @@ stages: - test - - deploy - build-doc - deploy-doc @@ -22,17 +21,6 @@ test:php-7.2: <<: *test_definition script: php vendor/bin/phpunit -deploy-packagist: - stage: deploy - image: chill/ci-image:php-7.2 - before_script: - # test that PACKAGIST USERNAME and PACKAGIST_TOKEN variable are set - - if [ -z ${PACKAGIST_USERNAME+x} ]; then echo "Please set PACKAGIST_USERNAME variable"; exit -1; fi - - if [ -z ${PACKAGIST_TOKEN+x} ]; then echo "Please set PACKAGIST_TOKEN variable"; exit -1; fi - script: - - STATUSCODE=$(curl -XPOST -H'content-type:application/json' "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_TOKEN" -d"{\"repository\":{\"url\":\"$CI_PROJECT_URL.git\"}}" --silent --output /dev/stderr --write-out "%{http_code}") - - if [ $STATUSCODE = "202" ]; then exit 0; else exit $STATUSCODE; fi - # deploy documentation api-doc-build: stage: build-doc From 6d8d99c5729c05ad753436ca6827b4a88f854f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 10 Sep 2018 14:28:37 +0200 Subject: [PATCH 181/210] upgrade deps to stable version --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index c528d89e4..b8d145378 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,9 @@ } ], "require": { - "chill-project/main": "dev-upgrade-sf3@dev", - "chill-project/custom-fields": "dev-upgrade-sf3@dev", - "chill-project/person": "dev-upgrade-sf3@dev" + "chill-project/main": "~1.5", + "chill-project/custom-fields": "~1.5", + "chill-project/person": "~1.5" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "~2.2", From 67d62e8d033f29d0b098a507674ab03392ae7b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 12 Sep 2018 10:57:55 +0200 Subject: [PATCH 182/210] [report list] fix "all fields are always shown" --- CHANGELOG.md | 6 ++++++ Export/Export/ReportList.php | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..4c307ed39 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ + +Branch master +============= + +- [list export] fix error "all custom fields are shown" + diff --git a/Export/Export/ReportList.php b/Export/Export/ReportList.php index 3da656aa0..583db8f4b 100644 --- a/Export/Export/ReportList.php +++ b/Export/Export/ReportList.php @@ -447,11 +447,14 @@ class ReportList implements ListInterface, ExportElementValidatedInterface $qb = $this->em->createQueryBuilder(); + // process fields which are not custom fields foreach ($this->fields as $f) { + // do not add fields which are not selected if (!\in_array($f, $data['fields'])) { continue; } + // add a column to the query for each field switch ($f) { case 'person_countryOfBirth': case 'person_nationality': @@ -500,10 +503,16 @@ class ReportList implements ListInterface, ExportElementValidatedInterface } + // process fields which are custom fields foreach ($this->getCustomFields() as $cf) { + // do not add custom fields which are not selected + if (!\in_array($cf->getSlug(), $data['fields'])) { + continue; + } $cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType()); + // if is multiple, split into multiple columns if ($cfType instanceof CustomFieldChoice and $cfType->isMultiple($cf)) { foreach($cfType->getChoices($cf) as $choiceSlug => $label) { $slug = $this->slugToDQL($cf->getSlug(), 'choice', [ 'choiceSlug' => $choiceSlug ]); @@ -513,6 +522,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface $qb->setParameter(sprintf('slug%s', $slug), $cf->getSlug()); } } else { + // not multiple, add a single column $slug = $this->slugToDQL($cf->getSlug()); $qb->addSelect( sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s', @@ -531,7 +541,6 @@ class ReportList implements ListInterface, ExportElementValidatedInterface ->setParameter('authorized_centers', $centers); ; - return $qb; } From b4c9cf06be01948cc3f56a03d0333f0e7efe1a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 12 Sep 2018 11:00:08 +0200 Subject: [PATCH 183/210] adapt changelog to 1.5.1 release --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c307ed39..6aed41285 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -Branch master +Version 1.5.1 ============= - [list export] fix error "all custom fields are shown" From 43a2e4705fc5ab6b7971a23fb458aa043dfa6df8 Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 16 Oct 2018 12:25:50 +0200 Subject: [PATCH 184/210] privacyEvent, add event on list and view actions --- Controller/ReportController.php | 34 +++++++++++++++++++- DependencyInjection/ChillReportExtension.php | 1 + Resources/config/services/controller.yml | 4 +++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Resources/config/services/controller.yml diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 6d9af377e..d24731bdd 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -21,6 +21,8 @@ namespace Chill\ReportBundle\Controller; +use Chill\PersonBundle\Privacy\PrivacyEvent; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -38,6 +40,22 @@ use Chill\ReportBundle\Form\ReportType; */ class ReportController extends Controller { + /** + * @var EventDispatcherInterface + */ + protected $eventDispatcher; + + /** + * ReportController constructor. + * + * @param EventDispatcherInterface $eventDispatcher + */ + public function __construct(EventDispatcherInterface $eventDispatcher) + { + $this->eventDispatcher = $eventDispatcher; + } + + /** * List all the report entities for a given person. * @@ -78,6 +96,12 @@ class ReportController extends Controller ->getResult() ; + $event = new PrivacyEvent($person, array( + 'element_class' => Report::class, + 'action' => 'list' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->render('ChillReportBundle:Report:list.html.twig', array( 'reports' => $reports, 'person' => $person, @@ -379,7 +403,15 @@ class ReportController extends Controller } $this->denyAccessUnlessGranted('CHILL_REPORT_SEE', $entity); - + + + $event = new PrivacyEvent($person, array( + 'element_class' => Report::class, + 'element_id' => intval($report_id), + 'action' => 'view' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->render('ChillReportBundle:Report:view.html.twig', array( 'entity' => $entity, 'person' => $person, diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index 56d8effc5..54d09580c 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -29,6 +29,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac $loader->load('services.yml'); $loader->load('services/fixtures.yml'); $loader->load('services/export.yml'); + $loader->load('services/controller.yml'); } /** diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml new file mode 100644 index 000000000..033cf4c15 --- /dev/null +++ b/Resources/config/services/controller.yml @@ -0,0 +1,4 @@ +services: + Chill\ReportBundle\Controller\ReportController: + arguments: + $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' From a3a4d31f8bd98cf4eb0422110e10d18540f09126 Mon Sep 17 00:00:00 2001 From: Mat Date: Fri, 19 Oct 2018 13:36:21 +0200 Subject: [PATCH 185/210] privacyEvent, update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aed41285..92ba9b954 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,9 @@ Version 1.5.1 - [list export] fix error "all custom fields are shown" + +PrivacyEvent branch +=================== + +- add privacy events to report list / view + From f0a0f46ff1c615d67c847219a2aec59549f9127e Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 23 Oct 2018 10:31:20 +0200 Subject: [PATCH 186/210] add privacyEvents for report edit and update --- CHANGELOG.md | 1 + Controller/ReportController.php | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92ba9b954..9d8a4b2e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,4 +9,5 @@ PrivacyEvent branch =================== - add privacy events to report list / view +- add privacy events to report edit / update diff --git a/Controller/ReportController.php b/Controller/ReportController.php index d24731bdd..ec3ce58d1 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -407,7 +407,7 @@ class ReportController extends Controller $event = new PrivacyEvent($person, array( 'element_class' => Report::class, - 'element_id' => intval($report_id), + 'element_id' => $entity->getId(), 'action' => 'view' )); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); @@ -446,6 +446,13 @@ class ReportController extends Controller $person = $report->getPerson(); $editForm = $this->createEditForm($report); + + $event = new PrivacyEvent($person, array( + 'element_class' => Report::class, + 'element_id' => $report->getId(), + 'action' => 'edit' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); return $this->render('ChillReportBundle:Report:edit.html.twig', array( 'edit_form' => $editForm->createView(), @@ -507,7 +514,16 @@ class ReportController extends Controller $this->get('translator') ->trans('Success : report updated!') ); - + + $person = $report->getPerson(); + + $event = new PrivacyEvent($person, array( + 'element_class' => Report::class, + 'element_id' => $report->getId(), + 'action' => 'update' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->redirect($this->generateUrl('report_view', array('person_id' => $report->getPerson()->getId(), 'report_id' => $report_id))); } From ac471906ec1c0efc4ddf3e3c07384810f2468df2 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 28 Feb 2019 10:52:55 +0100 Subject: [PATCH 187/210] adapt changelog to 1.5.2 release --- CHANGELOG.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d8a4b2e8..e0ed03792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,15 @@ Version 1.5.1 - [list export] fix error "all custom fields are shown" - -PrivacyEvent branch -=================== +Version 1.5.2 +============= - add privacy events to report list / view - add privacy events to report edit / update +Master branch +============= + + + + From 137294d8b8b5e1085fb0a5da478bd69b8ef54258 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 22 Jul 2020 17:05:24 +0200 Subject: [PATCH 188/210] fix sf4 deprecated: remove choices_as_values form option --- Controller/ReportController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index ec3ce58d1..cb09f1d4e 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -163,7 +163,6 @@ class ReportController extends Controller )) ->add('cFGroup', ChoiceType::class, array( 'choices' => array_combine(array_values($cFGroupsChoice),array_keys($cFGroupsChoice)), - 'choices_as_values' => true )) ->getForm(); @@ -216,7 +215,6 @@ class ReportController extends Controller )) ->add('cFGroup', ChoiceType::class, array( 'choices' => array_combine(array_values($cFGroupsChoice),array_keys($cFGroupsChoice)), - 'choices_as_values' => true )) ->getForm(); From a812a0c1322aea5b95cb6b9416241f5ce99503b0 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 23 Jul 2020 12:51:07 +0200 Subject: [PATCH 189/210] fix sf4 deprecated: improve relying AuthorizationHelper service --- Controller/ReportController.php | 12 ++++++++++-- Resources/config/services/controller.yml | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index cb09f1d4e..c89b1299b 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -21,6 +21,7 @@ namespace Chill\ReportBundle\Controller; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Privacy\PrivacyEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; @@ -45,14 +46,21 @@ class ReportController extends Controller */ protected $eventDispatcher; + /** + * @var AuthorizationHelper + */ + protected $authorizationHelper; + /** * ReportController constructor. * * @param EventDispatcherInterface $eventDispatcher + * @param AuthorizationHelper $authorizationHelper */ - public function __construct(EventDispatcherInterface $eventDispatcher) + public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper) { $this->eventDispatcher = $eventDispatcher; + $this->authorizationHelper = $authorizationHelper; } @@ -71,7 +79,7 @@ class ReportController extends Controller $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $reachableScopes = $this->get('chill.main.security.authorization.helper') + $reachableScopes = $this->authorizationHelper ->getReachableScopes($this->getUser(), new Role('CHILL_REPORT_SEE'), $person->getCenter()); diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 033cf4c15..42c2c1268 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -2,3 +2,5 @@ services: Chill\ReportBundle\Controller\ReportController: arguments: $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + tags: ['controller.service_arguments'] From 91c965cda693787587f22f0b73e8aa6d9e46ef7f Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 24 Jul 2020 18:08:55 +0200 Subject: [PATCH 190/210] sf4 deprecated: migrate Doctrine ORM mapping to annotation --- Entity/Report.php | 41 ++++++++++++++++-------- Resources/config/doctrine/Report.orm.yml | 25 --------------- 2 files changed, 28 insertions(+), 38 deletions(-) delete mode 100644 Resources/config/doctrine/Report.orm.yml diff --git a/Entity/Report.php b/Entity/Report.php index 31ba0a43a..038130411 100644 --- a/Entity/Report.php +++ b/Entity/Report.php @@ -20,50 +20,68 @@ namespace Chill\ReportBundle\Entity; +use Doctrine\ORM\Mapping as ORM; +use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Entity\Center; +use Chill\PersonBundle\Entity\Person; +use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasScopeInterface; -use Chill\MainBundle\Entity\Scope; -use Chill\MainBundle\Entity\User; -use Chill\PersonBundle\Entity\Person; use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; /** - * Report + * Class Report + * + * @package Chill\ReportBundle\Entity + * @ORM\Entity() + * @ORM\Table(null) + * @ORM\HasLifecycleCallbacks() */ class Report implements HasCenterInterface, HasScopeInterface { /** * @var integer + * + * @ORM\Id + * @ORM\Column(name="id", type="integer") + * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var User + * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") */ private $user; /** * @var Person + * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") */ private $person; /** * @var \DateTime + * @ORM\Column(type="datetime") */ private $date; /** * @var Scope + * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") */ private $scope; /** * @var array + * @ORM\Column(type="json_array") */ private $cFData; /** * @var CustomFieldsGroup + * @ORM\ManyToOne( + * targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldsGroup") */ private $cFGroup; @@ -81,8 +99,7 @@ class Report implements HasCenterInterface, HasScopeInterface /** * Set user * - * @param \User $user - * + * @param User $user * @return Report */ public function setUser(User $user) @@ -95,7 +112,7 @@ class Report implements HasCenterInterface, HasScopeInterface /** * Get user * - * @return \User + * @return User */ public function getUser() { @@ -106,7 +123,6 @@ class Report implements HasCenterInterface, HasScopeInterface * Set person * * @param Person $person - * * @return Report */ public function setPerson(Person $person) @@ -130,7 +146,6 @@ class Report implements HasCenterInterface, HasScopeInterface * Set date * * @param \DateTime $date - * * @return Report */ public function setDate($date) @@ -154,7 +169,6 @@ class Report implements HasCenterInterface, HasScopeInterface * Set scope * * @param string $scope - * * @return Report */ public function setScope(Scope $scope) @@ -178,7 +192,6 @@ class Report implements HasCenterInterface, HasScopeInterface * Set cFData * * @param array $cFData - * * @return Report */ public function setCFData(array $cFData) @@ -202,7 +215,6 @@ class Report implements HasCenterInterface, HasScopeInterface * Set cFGroup * * @param CustomFieldsGroup $cFGroup - * * @return Report */ public function setCFGroup(CustomFieldsGroup $cFGroup) @@ -221,7 +233,10 @@ class Report implements HasCenterInterface, HasScopeInterface { return $this->cFGroup; } - + + /** + * @return Center + */ public function getCenter() { return $this->person->getCenter(); diff --git a/Resources/config/doctrine/Report.orm.yml b/Resources/config/doctrine/Report.orm.yml deleted file mode 100644 index 7632a282d..000000000 --- a/Resources/config/doctrine/Report.orm.yml +++ /dev/null @@ -1,25 +0,0 @@ -Chill\ReportBundle\Entity\Report: - type: entity - table: null - id: - id: - type: integer - id: true - generator: - strategy: AUTO - fields: - date: - type: datetime - cFData: - type: json_array - manyToOne: - user: - targetEntity: Chill\MainBundle\Entity\User - person: - targetEntity: Chill\PersonBundle\Entity\Person - scope: - targetEntity: Chill\MainBundle\Entity\Scope - cFGroup: - targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldsGroup - lifecycleCallbacks: { } - \ No newline at end of file From b0013097789e3f563a0deda44c082f60ad8b420a Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 27 Jul 2020 13:50:23 +0200 Subject: [PATCH 191/210] sf4 deprecated: timeline builder was private service --- Resources/config/services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index fec944ff5..c35d12b8c 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -23,6 +23,7 @@ services: - '@security.token_storage' - '@chill.custom_field.helper' - '%chill_custom_fields.show_empty_values%' + public: true tags: - { name: chill.timeline, context: 'person' } From 0d435dcd9bc410875ceca8bd72f94b5de6b3402b Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 27 Jul 2020 16:16:17 +0200 Subject: [PATCH 192/210] fix sf4 minor corrections on Doctrine ORM mapping Entities --- Entity/Report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Entity/Report.php b/Entity/Report.php index 038130411..fa81d9283 100644 --- a/Entity/Report.php +++ b/Entity/Report.php @@ -34,7 +34,7 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; * * @package Chill\ReportBundle\Entity * @ORM\Entity() - * @ORM\Table(null) + * @ORM\Table(name="report") * @ORM\HasLifecycleCallbacks() */ class Report implements HasCenterInterface, HasScopeInterface From 6ca6974456402a88f42bbcb88d4b5f54307c32bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 28 Jul 2020 13:21:49 +0200 Subject: [PATCH 193/210] make timeline & paginator service private --- Resources/config/services.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index c35d12b8c..fec944ff5 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -23,7 +23,6 @@ services: - '@security.token_storage' - '@chill.custom_field.helper' - '%chill_custom_fields.show_empty_values%' - public: true tags: - { name: chill.timeline, context: 'person' } From b179ebba72f650dc1adc07222c008605fe52245e Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 28 Jul 2020 16:44:36 +0200 Subject: [PATCH 194/210] upgrade to symfony4, reset all requires into modules --- composer.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/composer.json b/composer.json index b8d145378..a5c17a2ee 100644 --- a/composer.json +++ b/composer.json @@ -19,16 +19,8 @@ } ], "require": { - "chill-project/main": "~1.5", - "chill-project/custom-fields": "~1.5", - "chill-project/person": "~1.5" }, "require-dev": { - "doctrine/doctrine-fixtures-bundle": "~2.2", - "fzaninotto/faker": "~1", - "monolog/monolog": "^1.14", - "symfony/monolog-bundle": "^2.7", - "phpunit/phpunit": "~5.0" }, "scripts": { "post-install-cmd": [ From f760943baaa24dffa92e6bdd6f289324dafaa44a Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 30 Jul 2020 14:25:28 +0200 Subject: [PATCH 195/210] rename syntax for ChillMain twig template calls --- Controller/ReportController.php | 2 +- Resources/views/Report/select_report_type_for_export.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index c89b1299b..b1075a146 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -228,7 +228,7 @@ class ReportController extends Controller return $this->render('ChillReportBundle:Report:select_report_type_for_export.html.twig', array( 'form' => $form->createView(), - 'layout_name' => "ChillMainBundle::Export/layout.html.twig" + 'layout_name' => "@ChillMain/Export/layout.html.twig" )); } diff --git a/Resources/views/Report/select_report_type_for_export.html.twig b/Resources/views/Report/select_report_type_for_export.html.twig index 55d0667e2..56232cfbe 100644 --- a/Resources/views/Report/select_report_type_for_export.html.twig +++ b/Resources/views/Report/select_report_type_for_export.html.twig @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "ChillMainBundle::Export/layout.html.twig" %} +{% extends "@ChillMain/Export/layout.html.twig" %} {% set activeRouteKey = 'report_export_list' %} From f707a649d1163f13be814a3a18f39fde481eba9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 31 Jul 2020 15:53:01 +0200 Subject: [PATCH 196/210] adapt migrations files to flex --- .../Version20141129012050.php | 6 +++--- .../Version20150622233319.php | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) rename {Resources/migrations => migrations}/Version20141129012050.php (91%) rename {Resources/migrations => migrations}/Version20150622233319.php (87%) diff --git a/Resources/migrations/Version20141129012050.php b/migrations/Version20141129012050.php similarity index 91% rename from Resources/migrations/Version20141129012050.php rename to migrations/Version20141129012050.php index a87ab505c..6e2aaf750 100644 --- a/Resources/migrations/Version20141129012050.php +++ b/migrations/Version20141129012050.php @@ -2,7 +2,7 @@ namespace Application\Migrations; -use Doctrine\DBAL\Migrations\AbstractMigration; +use Doctrine\Migrations\AbstractMigration; use Doctrine\DBAL\Schema\Schema; /** @@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\Schema; */ class Version20141129012050 extends AbstractMigration { - public function up(Schema $schema) + public function up(Schema $schema): void { $this->addSql("CREATE SEQUENCE Report_id_seq INCREMENT BY 1 MINVALUE 1 START 1;"); $this->addSql("CREATE TABLE Report (id INT NOT NULL, user_id INT DEFAULT NULL, person_id INT DEFAULT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, scope VARCHAR(255) DEFAULT NULL, cFData JSON NOT NULL, cFGroup_id INT DEFAULT NULL, PRIMARY KEY(id));"); @@ -22,7 +22,7 @@ class Version20141129012050 extends AbstractMigration $this->addSql("ALTER TABLE Report ADD CONSTRAINT FK_C38372B216D2C9F0 FOREIGN KEY (cFGroup_id) REFERENCES CustomFieldsGroup (id) NOT DEFERRABLE INITIALLY IMMEDIATE;"); } - public function down(Schema $schema) + public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs diff --git a/Resources/migrations/Version20150622233319.php b/migrations/Version20150622233319.php similarity index 87% rename from Resources/migrations/Version20150622233319.php rename to migrations/Version20150622233319.php index 7d4342a29..75ece3511 100644 --- a/Resources/migrations/Version20150622233319.php +++ b/migrations/Version20150622233319.php @@ -2,7 +2,7 @@ namespace Application\Migrations; -use Doctrine\DBAL\Migrations\AbstractMigration; +use Doctrine\Migrations\AbstractMigration; use Doctrine\DBAL\Schema\Schema; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Scope; class Version20150622233319 extends AbstractMigration implements ContainerAwareInterface { + /** * * @var ContainerInterface @@ -34,13 +35,23 @@ class Version20150622233319 extends AbstractMigration /** * @param Schema $schema */ - public function up(Schema $schema) + public function up(Schema $schema): void { $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE report ADD scope_id INT DEFAULT NULL'); + /* + * Before the upgrade to symfony version 4, this code worked. + * + * But it doesn't work any more after the migration and currently this + * code should note be necessary. + * + * This code is kept for reference, and may be re-activated if needed, but + * the probability that this will happens is near 0 + * + //add a default scope $scopes = $this->container->get('doctrine.orm.default_entity_manager') ->getRepository('ChillMainBundle:Scope') @@ -73,7 +84,7 @@ class Version20150622233319 extends AbstractMigration //default scope is the newly-created one $defaultScopeId = $scope->getId(); } - } + }*/ $this->addSql('ALTER TABLE report DROP scope'); //before this migration, scope was never used $this->addSql('ALTER TABLE report ADD CONSTRAINT FK_report_scope ' @@ -92,7 +103,7 @@ class Version20150622233319 extends AbstractMigration /** * @param Schema $schema */ - public function down(Schema $schema) + public function down(Schema $schema): void { $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); From d9832475148b6ae6f8157a4132c83a2f43fef3dd Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 3 Aug 2020 11:10:39 +0200 Subject: [PATCH 197/210] install twig intl-extra, replace localizeddate filter by format_date --- Resources/views/Report/export.csv.twig | 2 +- Resources/views/Report/list.html.twig | 2 +- Resources/views/Report/view.html.twig | 2 +- Resources/views/Search/results.html.twig | 2 +- Resources/views/Timeline/report_person_context.html.twig | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Resources/views/Report/export.csv.twig b/Resources/views/Report/export.csv.twig index e2dcb15c6..b0482afe9 100644 --- a/Resources/views/Report/export.csv.twig +++ b/Resources/views/Report/export.csv.twig @@ -13,7 +13,7 @@ #}{{ report.id }},{# #}"{{ report.person|csv_cell }}",{# #}"{{ report.person.id|csv_cell }}",{# - #}"{{ report.date|localizeddate('short', 'none') }}",{# + #}"{{ report.date|format_date('short', 'none') }}",{# #}"{{ report.user|csv_cell }}",{# #}"{{ report.cFGroup.getName(app.request.locale)|csv_cell }}",{# #}{% for customField in report.cFGroup.activeCustomFields %}{# diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index d9d603e10..350c0b0d2 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -41,7 +41,7 @@
    {% for report in reports %} - + - + diff --git a/Resources/views/Timeline/report_person_context.html.twig b/Resources/views/Timeline/report_person_context.html.twig index 48925ebdc..05a129929 100644 --- a/Resources/views/Timeline/report_person_context.html.twig +++ b/Resources/views/Timeline/report_person_context.html.twig @@ -1,11 +1,11 @@
    -

    {{ report.date|localizeddate('long', 'none') }} / {{ 'Report'|trans }}

    +

    {{ report.date|format_date('long', 'none') }} / {{ 'Report'|trans }}

    {{ '%user% has filled a %report_label% report'|trans( { '%user%' : user, '%report_label%': report.CFGroup.name|localize_translatable_string, - '%date%' : report.date|localizeddate('long', 'none') } + '%date%' : report.date|format_date('long', 'none') } ) }}
    {% if custom_fields_in_summary|length > 0 %} From 00c3d1cb9785badaf5a9135660108f93439645e6 Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 3 Aug 2020 21:15:03 +0200 Subject: [PATCH 198/210] sf4, fix errors with report bundle, adapt new config yaml directory --- DependencyInjection/ChillReportExtension.php | 12 ++++++------ DependencyInjection/Configuration.php | 4 ++-- Resources/translations/messages.fr.yml | 3 +-- Resources/translations/messages.nl.yml | 3 +-- Resources/config/routing.yml => config/routes.yaml | 0 .../config/services.yml => config/services.yaml | 0 .../services/controller.yaml | 0 .../export.yml => config/services/export.yaml | 0 .../fixtures.yml => config/services/fixtures.yaml | 2 +- .../config/validation.yml => config/validation.yaml | 0 10 files changed, 11 insertions(+), 13 deletions(-) rename Resources/config/routing.yml => config/routes.yaml (100%) rename Resources/config/services.yml => config/services.yaml (100%) rename Resources/config/services/controller.yml => config/services/controller.yaml (100%) rename Resources/config/services/export.yml => config/services/export.yaml (100%) rename Resources/config/services/fixtures.yml => config/services/fixtures.yaml (67%) rename Resources/config/validation.yml => config/validation.yaml (100%) diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index 54d09580c..359017020 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -25,11 +25,11 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.yml'); - $loader->load('services/fixtures.yml'); - $loader->load('services/export.yml'); - $loader->load('services/controller.yml'); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); + $loader->load('services.yaml'); + $loader->load('services/fixtures.yaml'); + $loader->load('services/export.yaml'); + $loader->load('services/controller.yaml'); } /** @@ -75,7 +75,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac $container->prependExtensionConfig('chill_main', array( 'routing' => array( 'resources' => array( - '@ChillReportBundle/Resources/config/routing.yml' + '@ChillReportBundle/config/routes.yaml' ) ) )); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index e9c959146..2b3b75672 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('chill_report'); + $treeBuilder = new TreeBuilder('chill_report'); + $rootNode = $treeBuilder->getRootNode('chill_report'); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 6ea3a2600..5bfd3f75a 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -14,7 +14,6 @@ Date: Date User: Utilisateur 'Report type': 'Type de rapport' 'View the report': "Voir le rapport" -'Update the report': "Mettre à jour le rapport" Report data: Données du rapport 'Report view : %name%': 'Rapport : %name%' Report: Rapport @@ -38,7 +37,7 @@ No report registered for this person.: Aucun rapport pour cette personne. '%total% reports matching the search "%pattern%"': '{0} Aucun rapport ne correspond à la recherche "%pattern%" | {1} Un rapport correspond à la recherche "%pattern%" | ]1,Inf]%total% rapports correspondent à la recherche "%pattern%"' #timeline -'%user% has filled a %report_label% report': %user% a ajouté un rapport '%report_label%' +'%user% has filled a %report_label% report': "%user% a ajouté un rapport '%report_label%'" #roles CHILL_REPORT_UPDATE: Modifier les rapports diff --git a/Resources/translations/messages.nl.yml b/Resources/translations/messages.nl.yml index adabc1d1c..54bd178ff 100644 --- a/Resources/translations/messages.nl.yml +++ b/Resources/translations/messages.nl.yml @@ -14,7 +14,6 @@ Date: Datum User: Gebruiker 'Report type': 'Soort of verslag' 'View the report': "Bekijk de consultatiegegevens" -'Update the report': "Update van de consultatiegegevens" #Flash messages 'Success : report created!': "De consultatiegegevens zijn correct ingevuld!" @@ -29,4 +28,4 @@ User: Gebruiker 'You are going to leave a page with unsubmitted data. Are you sure you want to leave ?': 'U bent aan te vertrekken een pagina die veranderdt datas behoudt. Bent u er zeker van dat u wil vertrekken ?' #timeline -'%user% has filled a %report_label% report on %date%': %user% heeft een rapport '%report_label%' toegevoegd om %date% +'%user% has filled a %report_label% report on %date%': "%user% heeft een rapport '%report_label%' toegevoegd om %date%" diff --git a/Resources/config/routing.yml b/config/routes.yaml similarity index 100% rename from Resources/config/routing.yml rename to config/routes.yaml diff --git a/Resources/config/services.yml b/config/services.yaml similarity index 100% rename from Resources/config/services.yml rename to config/services.yaml diff --git a/Resources/config/services/controller.yml b/config/services/controller.yaml similarity index 100% rename from Resources/config/services/controller.yml rename to config/services/controller.yaml diff --git a/Resources/config/services/export.yml b/config/services/export.yaml similarity index 100% rename from Resources/config/services/export.yml rename to config/services/export.yaml diff --git a/Resources/config/services/fixtures.yml b/config/services/fixtures.yaml similarity index 67% rename from Resources/config/services/fixtures.yml rename to config/services/fixtures.yaml index dfb34ddc4..6362bbfe7 100644 --- a/Resources/config/services/fixtures.yml +++ b/config/services/fixtures.yaml @@ -1,4 +1,4 @@ services: Chill\ReportBundle\DataFixtures\ORM\: - resource: ../../../DataFixtures/ORM + resource: ../../DataFixtures/ORM tags: [ 'doctrine.fixture.orm' ] \ No newline at end of file diff --git a/Resources/config/validation.yml b/config/validation.yaml similarity index 100% rename from Resources/config/validation.yml rename to config/validation.yaml From f7902dd9401b057d6dfd249c414023853a543544 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 4 Aug 2020 10:04:25 +0200 Subject: [PATCH 199/210] sf4, adding workflow and fix errors for task bundle --- Timeline/TimelineReportProvider.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Timeline/TimelineReportProvider.php b/Timeline/TimelineReportProvider.php index 6c60d222a..c6c13173a 100644 --- a/Timeline/TimelineReportProvider.php +++ b/Timeline/TimelineReportProvider.php @@ -23,7 +23,7 @@ namespace Chill\ReportBundle\Timeline; use Chill\MainBundle\Timeline\TimelineProviderInterface; use Doctrine\ORM\EntityManager; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Role\Role; use Doctrine\ORM\Mapping\ClassMetadata; use Chill\PersonBundle\Entity\Person; @@ -64,11 +64,27 @@ class TimelineReportProvider implements TimelineProviderInterface */ protected $customFieldsHelper; + /** + * @var + */ protected $showEmptyValues; - public function __construct(EntityManager $em, AuthorizationHelper $helper, - TokenStorage $storage, CustomFieldsHelper $customFieldsHelper, - $showEmptyValues) + /** + * TimelineReportProvider constructor. + * + * @param EntityManager $em + * @param AuthorizationHelper $helper + * @param TokenStorageInterface $storage + * @param CustomFieldsHelper $customFieldsHelper + * @param $showEmptyValues + */ + public function __construct( + EntityManager $em, + AuthorizationHelper $helper, + TokenStorageInterface $storage, + CustomFieldsHelper $customFieldsHelper, + $showEmptyValues + ) { $this->em = $em; $this->helper = $helper; From 1aecc2fd3a47883913e3b47a395f3e12f038bf1f Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 4 Aug 2020 16:28:07 +0200 Subject: [PATCH 200/210] move files from Resources/translations/ to translations/ --- {Resources/translations => translations}/messages.fr.yml | 0 {Resources/translations => translations}/messages.nl.yml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {Resources/translations => translations}/messages.fr.yml (100%) rename {Resources/translations => translations}/messages.nl.yml (100%) diff --git a/Resources/translations/messages.fr.yml b/translations/messages.fr.yml similarity index 100% rename from Resources/translations/messages.fr.yml rename to translations/messages.fr.yml diff --git a/Resources/translations/messages.nl.yml b/translations/messages.nl.yml similarity index 100% rename from Resources/translations/messages.nl.yml rename to translations/messages.nl.yml From 1d8d7fa354fc6d3c1348d7b0f94603266be74dac Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 4 Sep 2020 20:35:32 +0200 Subject: [PATCH 201/210] fix deprecated ObjectManager path in data fixtures scripts --- DataFixtures/ORM/LoadCustomField.php | 2 +- DataFixtures/ORM/LoadCustomFieldsGroup.php | 2 +- DataFixtures/ORM/LoadReportACL.php | 2 +- DataFixtures/ORM/LoadReports.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DataFixtures/ORM/LoadCustomField.php b/DataFixtures/ORM/LoadCustomField.php index 116e2a8e7..005f7d9ec 100644 --- a/DataFixtures/ORM/LoadCustomField.php +++ b/DataFixtures/ORM/LoadCustomField.php @@ -23,7 +23,7 @@ namespace Chill\ReportBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Chill\CustomFieldsBundle\Entity\CustomField; /** diff --git a/DataFixtures/ORM/LoadCustomFieldsGroup.php b/DataFixtures/ORM/LoadCustomFieldsGroup.php index fe033069e..ee45cc728 100644 --- a/DataFixtures/ORM/LoadCustomFieldsGroup.php +++ b/DataFixtures/ORM/LoadCustomFieldsGroup.php @@ -23,7 +23,7 @@ namespace Chill\ReportBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; /** diff --git a/DataFixtures/ORM/LoadReportACL.php b/DataFixtures/ORM/LoadReportACL.php index 429fac99c..f2a97c16d 100644 --- a/DataFixtures/ORM/LoadReportACL.php +++ b/DataFixtures/ORM/LoadReportACL.php @@ -21,7 +21,7 @@ namespace Chill\ReportBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\DataFixtures\ORM\LoadScopes; diff --git a/DataFixtures/ORM/LoadReports.php b/DataFixtures/ORM/LoadReports.php index 30eb419df..4e9ea028e 100644 --- a/DataFixtures/ORM/LoadReports.php +++ b/DataFixtures/ORM/LoadReports.php @@ -22,7 +22,7 @@ namespace Chill\ReportBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Chill\ReportBundle\Entity\Report; use Chill\MainBundle\DataFixtures\ORM\LoadUsers; From b2cbba4de89441b0485a83e995e8a29239aa1117 Mon Sep 17 00:00:00 2001 From: Tchama Date: Sun, 6 Sep 2020 20:32:46 +0200 Subject: [PATCH 202/210] use '@foo/bar.html.twig' syntax in twig templates --- Resources/views/Report/edit.html.twig | 2 +- Resources/views/Report/list.html.twig | 2 +- Resources/views/Report/new.html.twig | 2 +- Resources/views/Report/select_report_type.html.twig | 2 +- Resources/views/Report/view.html.twig | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Resources/views/Report/edit.html.twig b/Resources/views/Report/edit.html.twig index 47a7e4215..9ae03e174 100644 --- a/Resources/views/Report/edit.html.twig +++ b/Resources/views/Report/edit.html.twig @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "ChillPersonBundle::layout.html.twig" %} +{% extends "@ChillPerson/layout.html.twig" %} {% set activeRouteKey = 'report_select_type' %} diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index 350c0b0d2..fe6d90a65 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "ChillPersonBundle::layout.html.twig" %} +{% extends "@ChillPerson/layout.html.twig" %} {% set activeRouteKey = 'report_select_type' %} diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index 8589601ae..1fc18a735 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "ChillPersonBundle::layout.html.twig" %} +{% extends "@ChillPerson/layout.html.twig" %} {% set activeRouteKey = 'report_select_type' %} diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index 3297d5ef7..67983a7f8 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "ChillPersonBundle::layout.html.twig" %} +{% extends "@ChillPerson/layout.html.twig" %} {% set activeRouteKey = 'report_select_type' %} diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 5d80d59e9..503fb7910 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "ChillPersonBundle::layout.html.twig" %} +{% extends "@ChillPerson/layout.html.twig" %} {% set activeRouteKey = 'report_select_type' %} From 46293a9bafdd3fad72efa9b32a663b70561b620e Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 8 Sep 2020 15:42:42 +0200 Subject: [PATCH 203/210] rename deprecated using path for ObjectManager --- Form/ReportType.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Form/ReportType.php b/Form/ReportType.php index 3a0a1d6f2..d804dd6b8 100644 --- a/Form/ReportType.php +++ b/Form/ReportType.php @@ -29,7 +29,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Form\Extension\Core\Type\DateType; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Chill\CustomFieldsBundle\Form\Type\CustomFieldType; class ReportType extends AbstractType @@ -50,7 +50,7 @@ class ReportType extends AbstractType /** * - * @var \Doctrine\Common\Persistence\ObjectManager + * @var \Doctrine\Persistence\ObjectManager */ protected $om; From 0affc534c51eee3411c1715cc030ffa1724d9473 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 8 Sep 2020 18:26:37 +0200 Subject: [PATCH 204/210] inject PaginatorFactory in constructor --- Controller/ReportController.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index b1075a146..2c9a7f4bd 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -21,6 +21,7 @@ namespace Chill\ReportBundle\Controller; +use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Privacy\PrivacyEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -51,16 +52,27 @@ class ReportController extends Controller */ protected $authorizationHelper; + /** + * @var PaginatorFactory + */ + protected $paginator; + /** * ReportController constructor. * * @param EventDispatcherInterface $eventDispatcher * @param AuthorizationHelper $authorizationHelper + * @param PaginatorFactory $paginator */ - public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper) + public function __construct( + EventDispatcherInterface $eventDispatcher, + AuthorizationHelper $authorizationHelper, + PaginatorFactory $paginator + ) { $this->eventDispatcher = $eventDispatcher; $this->authorizationHelper = $authorizationHelper; + $this->paginator = $paginator; } @@ -91,7 +103,7 @@ class ReportController extends Controller ->getSingleScalarResult(); // get the PaginatorFactory - $paginator = $this->get('chill_main.paginator_factory')->create($total); + $paginator = $this->paginator->create($total); $reports = $em->createQuery('SELECT r FROM ChillReportBundle:Report r From 609a277f0330571c9bcd02bc722a968d794162be Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 10 Sep 2020 12:02:51 +0200 Subject: [PATCH 205/210] inject PaginatorFactory in constructor (omit) --- Controller/ReportController.php | 1 - config/services/controller.yaml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 2c9a7f4bd..fe0cb9767 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -30,7 +30,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Form\Extension\Core\Type\FormType; - use Chill\PersonBundle\Entity\Person; use Chill\ReportBundle\Entity\Report; use Chill\ReportBundle\Form\ReportType; diff --git a/config/services/controller.yaml b/config/services/controller.yaml index 42c2c1268..0eb58e45a 100644 --- a/config/services/controller.yaml +++ b/config/services/controller.yaml @@ -3,4 +3,5 @@ services: arguments: $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + $paginator: '@Chill\MainBundle\Pagination\PaginatorFactory' tags: ['controller.service_arguments'] From 675ae7fd5d1059411823c0e1d2d63427f30c71bf Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 10 Sep 2020 16:00:32 +0200 Subject: [PATCH 206/210] twig filter format_date need only one argument --- Resources/views/Report/list.html.twig | 2 +- Resources/views/Report/view.html.twig | 2 +- Resources/views/Search/results.html.twig | 2 +- Resources/views/Timeline/report_person_context.html.twig | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig index fe6d90a65..485771f51 100644 --- a/Resources/views/Report/list.html.twig +++ b/Resources/views/Report/list.html.twig @@ -41,7 +41,7 @@
    {% for report in reports %} - + - + diff --git a/Resources/views/Timeline/report_person_context.html.twig b/Resources/views/Timeline/report_person_context.html.twig index 05a129929..e9bcba85b 100644 --- a/Resources/views/Timeline/report_person_context.html.twig +++ b/Resources/views/Timeline/report_person_context.html.twig @@ -1,11 +1,11 @@
    -

    {{ report.date|format_date('long', 'none') }} / {{ 'Report'|trans }}

    +

    {{ report.date|format_date('long') }} / {{ 'Report'|trans }}

    {{ '%user% has filled a %report_label% report'|trans( { '%user%' : user, '%report_label%': report.CFGroup.name|localize_translatable_string, - '%date%' : report.date|format_date('long', 'none') } + '%date%' : report.date|format_date('long') } ) }}
    {% if custom_fields_in_summary|length > 0 %} From 750c3315d7e929bafd8a64b2537eccfde37d6b21 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 26 Jan 2021 15:21:21 +0100 Subject: [PATCH 207/210] translating all roles in admin interface --- translations/messages.fr.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/translations/messages.fr.yml b/translations/messages.fr.yml index 5bfd3f75a..9cd2d5d8c 100644 --- a/translations/messages.fr.yml +++ b/translations/messages.fr.yml @@ -43,6 +43,8 @@ No report registered for this person.: Aucun rapport pour cette personne. CHILL_REPORT_UPDATE: Modifier les rapports CHILL_REPORT_SEE: Voir les rapports CHILL_REPORT_CREATE: Créer des rapports +CHILL_REPORT_LISTS: Liste des rapports + #exports "List for report '%type%'": Liste des rapports "%type%" From 60cfa5ddd59785296f31e4efecb5c847eebafc02 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 1 Feb 2021 18:17:33 +0100 Subject: [PATCH 208/210] Replace deprecated extends Controller by AbstractController --- Controller/ReportController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index fe0cb9767..3cebec016 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -24,9 +24,9 @@ namespace Chill\ReportBundle\Controller; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Privacy\PrivacyEvent; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Form\Extension\Core\Type\FormType; @@ -36,10 +36,11 @@ use Chill\ReportBundle\Form\ReportType; /** - * Report controller. + * Class ReportController * + * @package Chill\ReportBundle\Controller */ -class ReportController extends Controller +class ReportController extends AbstractController { /** * @var EventDispatcherInterface From acf26ed5c8d0432d31cc520b6d90a964a0dd65bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 2 Mar 2021 17:15:52 +0100 Subject: [PATCH 209/210] change migration namespace --- migrations/Version20141129012050.php | 2 +- migrations/Version20150622233319.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migrations/Version20141129012050.php b/migrations/Version20141129012050.php index 6e2aaf750..3108024f8 100644 --- a/migrations/Version20141129012050.php +++ b/migrations/Version20141129012050.php @@ -1,6 +1,6 @@ Date: Thu, 18 Mar 2021 12:46:43 +0100 Subject: [PATCH 210/210] Prepare for moving into monorepo --- .gitignore => src/Bundle/ChillReport/.gitignore | 0 .../Bundle/ChillReport/.gitlab-ci.yml | 0 CHANGELOG.md => src/Bundle/ChillReport/CHANGELOG.md | 0 .../Bundle/ChillReport/ChillReportBundle.php | 0 .../ChillReport/Controller}/ReportController.php | 0 .../DataFixtures}/ORM/LoadCustomField.php | 0 .../DataFixtures}/ORM/LoadCustomFieldsGroup.php | 0 .../ChillReport/DataFixtures}/ORM/LoadReportACL.php | 0 .../ChillReport/DataFixtures}/ORM/LoadReports.php | 0 .../DependencyInjection}/ChillReportExtension.php | 0 .../DependencyInjection}/Configuration.php | 0 .../Bundle/ChillReport/Entity}/Report.php | 0 .../ChillReport/Export}/Export/ReportList.php | 0 .../Export}/Export/ReportListProvider.php | 0 .../ChillReport/Export}/Filter/ReportDateFilter.php | 0 .../Bundle/ChillReport/Form}/ReportType.php | 0 LICENSE => src/Bundle/ChillReport/LICENSE | 0 README.md => src/Bundle/ChillReport/README.md | 0 .../ChillReport/Resources}/test/Fixtures/.DS_Store | Bin .../Resources}/test/Fixtures/App/app/AppKernel.php | 0 .../Fixtures/App/app/DoctrineMigrations/.gitignore | 0 .../Resources}/test/Fixtures/App/app/autoload.php | 0 .../test/Fixtures/App/app/bootstrap.php.cache | 0 .../test/Fixtures/App/app/config/config.yml | 0 .../test/Fixtures/App/app/config/config_dev.yml | 0 .../test/Fixtures/App/app/config/config_test.yml | 0 .../App/app/config/parameters.gitlab-ci.yml | 0 .../test/Fixtures/App/app/config/parameters.yml | 0 .../Fixtures/App/app/config/parameters.yml.dist | 0 .../test/Fixtures/App/app/config/routing.yml | 0 .../Resources}/test/Fixtures/App/app/console | 0 .../Resources}/test/Fixtures/App/web/.gitignore | 0 .../Resources}/views/Report/edit.html.twig | 0 .../Resources}/views/Report/export.csv.twig | 0 .../Resources}/views/Report/list.html.twig | 0 .../Resources}/views/Report/new.html.twig | 0 .../views/Report/select_report_type.html.twig | 0 .../Report/select_report_type_for_export.html.twig | 0 .../Resources}/views/Report/view.html.twig | 0 .../Resources}/views/Search/results.html.twig | 0 .../views/Timeline/report_person_context.html.twig | 0 .../Bundle/ChillReport/Search}/ReportSearch.php | 0 .../Security}/Authorization/ReportVoter.php | 0 .../Tests}/Controller/ReportControllerNextTest.php | 0 .../Tests}/Controller/ReportControllerTest.php | 0 .../ChillReportExtensionTest.php | 0 .../ChillReport/Tests}/Search/ReportSearchTest.php | 0 .../Security/Authorization/ReportVoterTest.php | 0 .../Tests}/Timeline/TimelineProviderTest.php | 0 .../Bundle/ChillReport/Tests}/bootstrap.php | 0 .../Timeline}/TimelineReportProvider.php | 0 apigen.neon => src/Bundle/ChillReport/apigen.neon | 0 .../Bundle/ChillReport/composer.json | 0 .../Bundle/ChillReport/config}/routes.yaml | 0 .../Bundle/ChillReport/config}/services.yaml | 0 .../ChillReport/config}/services/controller.yaml | 0 .../Bundle/ChillReport/config}/services/export.yaml | 0 .../ChillReport/config}/services/fixtures.yaml | 0 .../Bundle/ChillReport/config}/validation.yaml | 0 console.sh => src/Bundle/ChillReport/console.sh | 0 .../migrations}/Version20141129012050.php | 0 .../migrations}/Version20150622233319.php | 0 .../Bundle/ChillReport/phpunit.xml.dist | 0 .../ChillReport/translations}/messages.fr.yml | 0 .../ChillReport/translations}/messages.nl.yml | 0 65 files changed, 0 insertions(+), 0 deletions(-) rename .gitignore => src/Bundle/ChillReport/.gitignore (100%) rename .gitlab-ci.yml => src/Bundle/ChillReport/.gitlab-ci.yml (100%) rename CHANGELOG.md => src/Bundle/ChillReport/CHANGELOG.md (100%) rename ChillReportBundle.php => src/Bundle/ChillReport/ChillReportBundle.php (100%) rename {Controller => src/Bundle/ChillReport/Controller}/ReportController.php (100%) rename {DataFixtures => src/Bundle/ChillReport/DataFixtures}/ORM/LoadCustomField.php (100%) rename {DataFixtures => src/Bundle/ChillReport/DataFixtures}/ORM/LoadCustomFieldsGroup.php (100%) rename {DataFixtures => src/Bundle/ChillReport/DataFixtures}/ORM/LoadReportACL.php (100%) rename {DataFixtures => src/Bundle/ChillReport/DataFixtures}/ORM/LoadReports.php (100%) rename {DependencyInjection => src/Bundle/ChillReport/DependencyInjection}/ChillReportExtension.php (100%) rename {DependencyInjection => src/Bundle/ChillReport/DependencyInjection}/Configuration.php (100%) rename {Entity => src/Bundle/ChillReport/Entity}/Report.php (100%) rename {Export => src/Bundle/ChillReport/Export}/Export/ReportList.php (100%) rename {Export => src/Bundle/ChillReport/Export}/Export/ReportListProvider.php (100%) rename {Export => src/Bundle/ChillReport/Export}/Filter/ReportDateFilter.php (100%) rename {Form => src/Bundle/ChillReport/Form}/ReportType.php (100%) rename LICENSE => src/Bundle/ChillReport/LICENSE (100%) rename README.md => src/Bundle/ChillReport/README.md (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/.DS_Store (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/AppKernel.php (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/DoctrineMigrations/.gitignore (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/autoload.php (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/bootstrap.php.cache (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/config/config.yml (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/config/config_dev.yml (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/config/config_test.yml (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/config/parameters.gitlab-ci.yml (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/config/parameters.yml (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/config/parameters.yml.dist (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/config/routing.yml (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/app/console (100%) rename {Resources => src/Bundle/ChillReport/Resources}/test/Fixtures/App/web/.gitignore (100%) rename {Resources => src/Bundle/ChillReport/Resources}/views/Report/edit.html.twig (100%) rename {Resources => src/Bundle/ChillReport/Resources}/views/Report/export.csv.twig (100%) rename {Resources => src/Bundle/ChillReport/Resources}/views/Report/list.html.twig (100%) rename {Resources => src/Bundle/ChillReport/Resources}/views/Report/new.html.twig (100%) rename {Resources => src/Bundle/ChillReport/Resources}/views/Report/select_report_type.html.twig (100%) rename {Resources => src/Bundle/ChillReport/Resources}/views/Report/select_report_type_for_export.html.twig (100%) rename {Resources => src/Bundle/ChillReport/Resources}/views/Report/view.html.twig (100%) rename {Resources => src/Bundle/ChillReport/Resources}/views/Search/results.html.twig (100%) rename {Resources => src/Bundle/ChillReport/Resources}/views/Timeline/report_person_context.html.twig (100%) rename {Search => src/Bundle/ChillReport/Search}/ReportSearch.php (100%) rename {Security => src/Bundle/ChillReport/Security}/Authorization/ReportVoter.php (100%) rename {Tests => src/Bundle/ChillReport/Tests}/Controller/ReportControllerNextTest.php (100%) rename {Tests => src/Bundle/ChillReport/Tests}/Controller/ReportControllerTest.php (100%) rename {Tests => src/Bundle/ChillReport/Tests}/DependencyInjection/ChillReportExtensionTest.php (100%) rename {Tests => src/Bundle/ChillReport/Tests}/Search/ReportSearchTest.php (100%) rename {Tests => src/Bundle/ChillReport/Tests}/Security/Authorization/ReportVoterTest.php (100%) rename {Tests => src/Bundle/ChillReport/Tests}/Timeline/TimelineProviderTest.php (100%) rename {Tests => src/Bundle/ChillReport/Tests}/bootstrap.php (100%) rename {Timeline => src/Bundle/ChillReport/Timeline}/TimelineReportProvider.php (100%) rename apigen.neon => src/Bundle/ChillReport/apigen.neon (100%) rename composer.json => src/Bundle/ChillReport/composer.json (100%) rename {config => src/Bundle/ChillReport/config}/routes.yaml (100%) rename {config => src/Bundle/ChillReport/config}/services.yaml (100%) rename {config => src/Bundle/ChillReport/config}/services/controller.yaml (100%) rename {config => src/Bundle/ChillReport/config}/services/export.yaml (100%) rename {config => src/Bundle/ChillReport/config}/services/fixtures.yaml (100%) rename {config => src/Bundle/ChillReport/config}/validation.yaml (100%) rename console.sh => src/Bundle/ChillReport/console.sh (100%) rename {migrations => src/Bundle/ChillReport/migrations}/Version20141129012050.php (100%) rename {migrations => src/Bundle/ChillReport/migrations}/Version20150622233319.php (100%) rename phpunit.xml.dist => src/Bundle/ChillReport/phpunit.xml.dist (100%) rename {translations => src/Bundle/ChillReport/translations}/messages.fr.yml (100%) rename {translations => src/Bundle/ChillReport/translations}/messages.nl.yml (100%) diff --git a/.gitignore b/src/Bundle/ChillReport/.gitignore similarity index 100% rename from .gitignore rename to src/Bundle/ChillReport/.gitignore diff --git a/.gitlab-ci.yml b/src/Bundle/ChillReport/.gitlab-ci.yml similarity index 100% rename from .gitlab-ci.yml rename to src/Bundle/ChillReport/.gitlab-ci.yml diff --git a/CHANGELOG.md b/src/Bundle/ChillReport/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to src/Bundle/ChillReport/CHANGELOG.md diff --git a/ChillReportBundle.php b/src/Bundle/ChillReport/ChillReportBundle.php similarity index 100% rename from ChillReportBundle.php rename to src/Bundle/ChillReport/ChillReportBundle.php diff --git a/Controller/ReportController.php b/src/Bundle/ChillReport/Controller/ReportController.php similarity index 100% rename from Controller/ReportController.php rename to src/Bundle/ChillReport/Controller/ReportController.php diff --git a/DataFixtures/ORM/LoadCustomField.php b/src/Bundle/ChillReport/DataFixtures/ORM/LoadCustomField.php similarity index 100% rename from DataFixtures/ORM/LoadCustomField.php rename to src/Bundle/ChillReport/DataFixtures/ORM/LoadCustomField.php diff --git a/DataFixtures/ORM/LoadCustomFieldsGroup.php b/src/Bundle/ChillReport/DataFixtures/ORM/LoadCustomFieldsGroup.php similarity index 100% rename from DataFixtures/ORM/LoadCustomFieldsGroup.php rename to src/Bundle/ChillReport/DataFixtures/ORM/LoadCustomFieldsGroup.php diff --git a/DataFixtures/ORM/LoadReportACL.php b/src/Bundle/ChillReport/DataFixtures/ORM/LoadReportACL.php similarity index 100% rename from DataFixtures/ORM/LoadReportACL.php rename to src/Bundle/ChillReport/DataFixtures/ORM/LoadReportACL.php diff --git a/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReport/DataFixtures/ORM/LoadReports.php similarity index 100% rename from DataFixtures/ORM/LoadReports.php rename to src/Bundle/ChillReport/DataFixtures/ORM/LoadReports.php diff --git a/DependencyInjection/ChillReportExtension.php b/src/Bundle/ChillReport/DependencyInjection/ChillReportExtension.php similarity index 100% rename from DependencyInjection/ChillReportExtension.php rename to src/Bundle/ChillReport/DependencyInjection/ChillReportExtension.php diff --git a/DependencyInjection/Configuration.php b/src/Bundle/ChillReport/DependencyInjection/Configuration.php similarity index 100% rename from DependencyInjection/Configuration.php rename to src/Bundle/ChillReport/DependencyInjection/Configuration.php diff --git a/Entity/Report.php b/src/Bundle/ChillReport/Entity/Report.php similarity index 100% rename from Entity/Report.php rename to src/Bundle/ChillReport/Entity/Report.php diff --git a/Export/Export/ReportList.php b/src/Bundle/ChillReport/Export/Export/ReportList.php similarity index 100% rename from Export/Export/ReportList.php rename to src/Bundle/ChillReport/Export/Export/ReportList.php diff --git a/Export/Export/ReportListProvider.php b/src/Bundle/ChillReport/Export/Export/ReportListProvider.php similarity index 100% rename from Export/Export/ReportListProvider.php rename to src/Bundle/ChillReport/Export/Export/ReportListProvider.php diff --git a/Export/Filter/ReportDateFilter.php b/src/Bundle/ChillReport/Export/Filter/ReportDateFilter.php similarity index 100% rename from Export/Filter/ReportDateFilter.php rename to src/Bundle/ChillReport/Export/Filter/ReportDateFilter.php diff --git a/Form/ReportType.php b/src/Bundle/ChillReport/Form/ReportType.php similarity index 100% rename from Form/ReportType.php rename to src/Bundle/ChillReport/Form/ReportType.php diff --git a/LICENSE b/src/Bundle/ChillReport/LICENSE similarity index 100% rename from LICENSE rename to src/Bundle/ChillReport/LICENSE diff --git a/README.md b/src/Bundle/ChillReport/README.md similarity index 100% rename from README.md rename to src/Bundle/ChillReport/README.md diff --git a/Resources/test/Fixtures/.DS_Store b/src/Bundle/ChillReport/Resources/test/Fixtures/.DS_Store similarity index 100% rename from Resources/test/Fixtures/.DS_Store rename to src/Bundle/ChillReport/Resources/test/Fixtures/.DS_Store diff --git a/Resources/test/Fixtures/App/app/AppKernel.php b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/AppKernel.php similarity index 100% rename from Resources/test/Fixtures/App/app/AppKernel.php rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/AppKernel.php diff --git a/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore similarity index 100% rename from Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore diff --git a/Resources/test/Fixtures/App/app/autoload.php b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/autoload.php similarity index 100% rename from Resources/test/Fixtures/App/app/autoload.php rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/autoload.php diff --git a/Resources/test/Fixtures/App/app/bootstrap.php.cache b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/bootstrap.php.cache similarity index 100% rename from Resources/test/Fixtures/App/app/bootstrap.php.cache rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/bootstrap.php.cache diff --git a/Resources/test/Fixtures/App/app/config/config.yml b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/config.yml similarity index 100% rename from Resources/test/Fixtures/App/app/config/config.yml rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/config.yml diff --git a/Resources/test/Fixtures/App/app/config/config_dev.yml b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/config_dev.yml similarity index 100% rename from Resources/test/Fixtures/App/app/config/config_dev.yml rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/config_dev.yml diff --git a/Resources/test/Fixtures/App/app/config/config_test.yml b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/config_test.yml similarity index 100% rename from Resources/test/Fixtures/App/app/config/config_test.yml rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/config_test.yml diff --git a/Resources/test/Fixtures/App/app/config/parameters.gitlab-ci.yml b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/parameters.gitlab-ci.yml similarity index 100% rename from Resources/test/Fixtures/App/app/config/parameters.gitlab-ci.yml rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/parameters.gitlab-ci.yml diff --git a/Resources/test/Fixtures/App/app/config/parameters.yml b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/parameters.yml similarity index 100% rename from Resources/test/Fixtures/App/app/config/parameters.yml rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/parameters.yml diff --git a/Resources/test/Fixtures/App/app/config/parameters.yml.dist b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/parameters.yml.dist similarity index 100% rename from Resources/test/Fixtures/App/app/config/parameters.yml.dist rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/parameters.yml.dist diff --git a/Resources/test/Fixtures/App/app/config/routing.yml b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/routing.yml similarity index 100% rename from Resources/test/Fixtures/App/app/config/routing.yml rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/config/routing.yml diff --git a/Resources/test/Fixtures/App/app/console b/src/Bundle/ChillReport/Resources/test/Fixtures/App/app/console similarity index 100% rename from Resources/test/Fixtures/App/app/console rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/app/console diff --git a/Resources/test/Fixtures/App/web/.gitignore b/src/Bundle/ChillReport/Resources/test/Fixtures/App/web/.gitignore similarity index 100% rename from Resources/test/Fixtures/App/web/.gitignore rename to src/Bundle/ChillReport/Resources/test/Fixtures/App/web/.gitignore diff --git a/Resources/views/Report/edit.html.twig b/src/Bundle/ChillReport/Resources/views/Report/edit.html.twig similarity index 100% rename from Resources/views/Report/edit.html.twig rename to src/Bundle/ChillReport/Resources/views/Report/edit.html.twig diff --git a/Resources/views/Report/export.csv.twig b/src/Bundle/ChillReport/Resources/views/Report/export.csv.twig similarity index 100% rename from Resources/views/Report/export.csv.twig rename to src/Bundle/ChillReport/Resources/views/Report/export.csv.twig diff --git a/Resources/views/Report/list.html.twig b/src/Bundle/ChillReport/Resources/views/Report/list.html.twig similarity index 100% rename from Resources/views/Report/list.html.twig rename to src/Bundle/ChillReport/Resources/views/Report/list.html.twig diff --git a/Resources/views/Report/new.html.twig b/src/Bundle/ChillReport/Resources/views/Report/new.html.twig similarity index 100% rename from Resources/views/Report/new.html.twig rename to src/Bundle/ChillReport/Resources/views/Report/new.html.twig diff --git a/Resources/views/Report/select_report_type.html.twig b/src/Bundle/ChillReport/Resources/views/Report/select_report_type.html.twig similarity index 100% rename from Resources/views/Report/select_report_type.html.twig rename to src/Bundle/ChillReport/Resources/views/Report/select_report_type.html.twig diff --git a/Resources/views/Report/select_report_type_for_export.html.twig b/src/Bundle/ChillReport/Resources/views/Report/select_report_type_for_export.html.twig similarity index 100% rename from Resources/views/Report/select_report_type_for_export.html.twig rename to src/Bundle/ChillReport/Resources/views/Report/select_report_type_for_export.html.twig diff --git a/Resources/views/Report/view.html.twig b/src/Bundle/ChillReport/Resources/views/Report/view.html.twig similarity index 100% rename from Resources/views/Report/view.html.twig rename to src/Bundle/ChillReport/Resources/views/Report/view.html.twig diff --git a/Resources/views/Search/results.html.twig b/src/Bundle/ChillReport/Resources/views/Search/results.html.twig similarity index 100% rename from Resources/views/Search/results.html.twig rename to src/Bundle/ChillReport/Resources/views/Search/results.html.twig diff --git a/Resources/views/Timeline/report_person_context.html.twig b/src/Bundle/ChillReport/Resources/views/Timeline/report_person_context.html.twig similarity index 100% rename from Resources/views/Timeline/report_person_context.html.twig rename to src/Bundle/ChillReport/Resources/views/Timeline/report_person_context.html.twig diff --git a/Search/ReportSearch.php b/src/Bundle/ChillReport/Search/ReportSearch.php similarity index 100% rename from Search/ReportSearch.php rename to src/Bundle/ChillReport/Search/ReportSearch.php diff --git a/Security/Authorization/ReportVoter.php b/src/Bundle/ChillReport/Security/Authorization/ReportVoter.php similarity index 100% rename from Security/Authorization/ReportVoter.php rename to src/Bundle/ChillReport/Security/Authorization/ReportVoter.php diff --git a/Tests/Controller/ReportControllerNextTest.php b/src/Bundle/ChillReport/Tests/Controller/ReportControllerNextTest.php similarity index 100% rename from Tests/Controller/ReportControllerNextTest.php rename to src/Bundle/ChillReport/Tests/Controller/ReportControllerNextTest.php diff --git a/Tests/Controller/ReportControllerTest.php b/src/Bundle/ChillReport/Tests/Controller/ReportControllerTest.php similarity index 100% rename from Tests/Controller/ReportControllerTest.php rename to src/Bundle/ChillReport/Tests/Controller/ReportControllerTest.php diff --git a/Tests/DependencyInjection/ChillReportExtensionTest.php b/src/Bundle/ChillReport/Tests/DependencyInjection/ChillReportExtensionTest.php similarity index 100% rename from Tests/DependencyInjection/ChillReportExtensionTest.php rename to src/Bundle/ChillReport/Tests/DependencyInjection/ChillReportExtensionTest.php diff --git a/Tests/Search/ReportSearchTest.php b/src/Bundle/ChillReport/Tests/Search/ReportSearchTest.php similarity index 100% rename from Tests/Search/ReportSearchTest.php rename to src/Bundle/ChillReport/Tests/Search/ReportSearchTest.php diff --git a/Tests/Security/Authorization/ReportVoterTest.php b/src/Bundle/ChillReport/Tests/Security/Authorization/ReportVoterTest.php similarity index 100% rename from Tests/Security/Authorization/ReportVoterTest.php rename to src/Bundle/ChillReport/Tests/Security/Authorization/ReportVoterTest.php diff --git a/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReport/Tests/Timeline/TimelineProviderTest.php similarity index 100% rename from Tests/Timeline/TimelineProviderTest.php rename to src/Bundle/ChillReport/Tests/Timeline/TimelineProviderTest.php diff --git a/Tests/bootstrap.php b/src/Bundle/ChillReport/Tests/bootstrap.php similarity index 100% rename from Tests/bootstrap.php rename to src/Bundle/ChillReport/Tests/bootstrap.php diff --git a/Timeline/TimelineReportProvider.php b/src/Bundle/ChillReport/Timeline/TimelineReportProvider.php similarity index 100% rename from Timeline/TimelineReportProvider.php rename to src/Bundle/ChillReport/Timeline/TimelineReportProvider.php diff --git a/apigen.neon b/src/Bundle/ChillReport/apigen.neon similarity index 100% rename from apigen.neon rename to src/Bundle/ChillReport/apigen.neon diff --git a/composer.json b/src/Bundle/ChillReport/composer.json similarity index 100% rename from composer.json rename to src/Bundle/ChillReport/composer.json diff --git a/config/routes.yaml b/src/Bundle/ChillReport/config/routes.yaml similarity index 100% rename from config/routes.yaml rename to src/Bundle/ChillReport/config/routes.yaml diff --git a/config/services.yaml b/src/Bundle/ChillReport/config/services.yaml similarity index 100% rename from config/services.yaml rename to src/Bundle/ChillReport/config/services.yaml diff --git a/config/services/controller.yaml b/src/Bundle/ChillReport/config/services/controller.yaml similarity index 100% rename from config/services/controller.yaml rename to src/Bundle/ChillReport/config/services/controller.yaml diff --git a/config/services/export.yaml b/src/Bundle/ChillReport/config/services/export.yaml similarity index 100% rename from config/services/export.yaml rename to src/Bundle/ChillReport/config/services/export.yaml diff --git a/config/services/fixtures.yaml b/src/Bundle/ChillReport/config/services/fixtures.yaml similarity index 100% rename from config/services/fixtures.yaml rename to src/Bundle/ChillReport/config/services/fixtures.yaml diff --git a/config/validation.yaml b/src/Bundle/ChillReport/config/validation.yaml similarity index 100% rename from config/validation.yaml rename to src/Bundle/ChillReport/config/validation.yaml diff --git a/console.sh b/src/Bundle/ChillReport/console.sh similarity index 100% rename from console.sh rename to src/Bundle/ChillReport/console.sh diff --git a/migrations/Version20141129012050.php b/src/Bundle/ChillReport/migrations/Version20141129012050.php similarity index 100% rename from migrations/Version20141129012050.php rename to src/Bundle/ChillReport/migrations/Version20141129012050.php diff --git a/migrations/Version20150622233319.php b/src/Bundle/ChillReport/migrations/Version20150622233319.php similarity index 100% rename from migrations/Version20150622233319.php rename to src/Bundle/ChillReport/migrations/Version20150622233319.php diff --git a/phpunit.xml.dist b/src/Bundle/ChillReport/phpunit.xml.dist similarity index 100% rename from phpunit.xml.dist rename to src/Bundle/ChillReport/phpunit.xml.dist diff --git a/translations/messages.fr.yml b/src/Bundle/ChillReport/translations/messages.fr.yml similarity index 100% rename from translations/messages.fr.yml rename to src/Bundle/ChillReport/translations/messages.fr.yml diff --git a/translations/messages.nl.yml b/src/Bundle/ChillReport/translations/messages.nl.yml similarity index 100% rename from translations/messages.nl.yml rename to src/Bundle/ChillReport/translations/messages.nl.yml
    {{ 'Date' | trans }} {{ 'Report type' | trans }} {{ 'Circle' | trans }}{{ 'Actions'|trans }} 
    {% if report.date %}{{ report.date|localizeddate('long', 'none') }}{% endif %}{% if report.date %}{{ report.date|format_date('long', 'none') }}{% endif %} {{ report.cFGroup.getName|localize_translatable_string }} {{ report.scope.name|localize_translatable_string }} diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 286313366..5d80d59e9 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -32,7 +32,7 @@
    {{ 'Circle'|trans }} :
    {{ entity.scope.name|localize_translatable_string }}
    {{ 'Date'|trans }} :
    -
    {{ entity.date|localizeddate('long', 'none') }}
    +
    {{ entity.date|format_date('long', 'none') }}
    {{ 'User'|trans }} :
    {{ entity.user }}
    diff --git a/Resources/views/Search/results.html.twig b/Resources/views/Search/results.html.twig index 94f0cd0cf..55a93888e 100644 --- a/Resources/views/Search/results.html.twig +++ b/Resources/views/Search/results.html.twig @@ -34,7 +34,7 @@ {% for report in reports %}
    {{ report.person }}{% if report.date %}{{ report.date|localizeddate('long', 'none') }}{% endif %}{% if report.date %}{{ report.date|format_date('long', 'none') }}{% endif %} {{ report.cFGroup.getName|localize_translatable_string }} {{ report.scope.name|localize_translatable_string }} {{ 'View the report' | trans }}
    {% if report.date %}{{ report.date|format_date('long', 'none') }}{% endif %}{% if report.date %}{{ report.date|format_date('long') }}{% endif %} {{ report.cFGroup.getName|localize_translatable_string }} {{ report.scope.name|localize_translatable_string }} diff --git a/Resources/views/Report/view.html.twig b/Resources/views/Report/view.html.twig index 503fb7910..f1c6ffdae 100644 --- a/Resources/views/Report/view.html.twig +++ b/Resources/views/Report/view.html.twig @@ -32,7 +32,7 @@
    {{ 'Circle'|trans }} :
    {{ entity.scope.name|localize_translatable_string }}
    {{ 'Date'|trans }} :
    -
    {{ entity.date|format_date('long', 'none') }}
    +
    {{ entity.date|format_date('long') }}
    {{ 'User'|trans }} :
    {{ entity.user }}
    diff --git a/Resources/views/Search/results.html.twig b/Resources/views/Search/results.html.twig index 55a93888e..68367bebd 100644 --- a/Resources/views/Search/results.html.twig +++ b/Resources/views/Search/results.html.twig @@ -34,7 +34,7 @@ {% for report in reports %}
    {{ report.person }}{% if report.date %}{{ report.date|format_date('long', 'none') }}{% endif %}{% if report.date %}{{ report.date|format_date('long') }}{% endif %} {{ report.cFGroup.getName|localize_translatable_string }} {{ report.scope.name|localize_translatable_string }} {{ 'View the report' | trans }}